export declare const MAINTENANCE_PROGRESS_FILE = "maintenance-progress.json"; export type MaintenanceOperation = "backup" | "restore" | "reset"; export type MaintenancePhase = "preparing" | "snapshotting" | "packing" | "stopping" | "extracting" | "clearing" | "migrating" | "starting" | "done" | "failed"; export interface MaintenanceProgress { operation: MaintenanceOperation; phase: MaintenancePhase; /** ‎0..100‎ على العملية كلّها، لا على الخطوة الحالية. */ percent: number; startedAt: string; finishedAt?: string; /** اسم الأرشيف — في الاستعادة وحدها. */ archiveId?: string; /** * AR: العملية التي تكتب هذا الملفّ. **بدونه لا يُفرَّق بين استعادةٍ تجري واستعادةٍ ماتت.** * انقطاعُ كهرباء في منتصف فكٍّ يترك ملفًّا يقول «extracting» إلى الأبد، وقارئُه ينتظر * تقدّمًا لن يأتي — واللوحة ترفض كل عمليةٍ جديدة لأن واحدةً «تجري». * EN: The process writing this file. **Without it, a restore in progress cannot be told from one * that died.** A power cut mid-extract leaves a file saying "extracting" forever, and its * reader waits on progress that never comes — while the dashboard refuses every new operation * because one is "running". */ pid: number; /** سبب الفشل ونتيجة التراجع معه. لا يُملأ عند النجاح. */ message?: string; } /** * AR: موضع الشريط كلّه من عمليةٍ ومرحلةٍ وتقدّمٍ داخلها. **دالّة نقيّة لأن الخطأ فيها لا يُرى إلّا * كارتدادٍ في الشريط أمام المالك** — وهو ما يُقرأ عطلًا لا تقدّمًا. * * و‎within‎ يخصّ ما يمكن قياسه (بايتات الأرشيف، ومداخل الفكّ) وحده. أمّا «تطبيق الهجرات» * فخطوةٌ لا تُقاس، فتُرسَم عند بداية مداها ويتقدّم الشريط بانتقالها — وادّعاءُ نسبةٍ داخلها * اختراعٌ لا قياس. * EN: The position on the whole bar, from an operation, a phase and the progress within it. **A pure * function because a mistake in it is visible only as the bar going backwards in front of the * owner** — which reads as a fault rather than as progress. * * `within` concerns only what can be measured (archive bytes, extracted entries). "Applying * migrations" is a step that cannot be measured, so it is drawn at the start of its range and the * bar advances as it changes; claiming a percentage inside it would be invention. */ export declare function overallPercent(operation: MaintenanceOperation, phase: MaintenancePhase, within?: number): number; /** * AR: يكتب الحالة، **ولا يرمي أبدًا**. هذا الملفّ رفاهيةُ عرض؛ وتعذّرُ كتابته — قرصٌ ممتلئ، أو * صلاحية — لا يجوز أن يُسقط استعادةً تجري على بيانات عميل **في منتصفها**. * * **والكتابة ذرّية: ملفٌّ مؤقّت ثم إعادة تسمية.** القارئ عمليةٌ أخرى تقرأ متى شاءت، وكتابةٌ * مباشرة تعرّضه لنصف JSON فيقرأ «تالف» عن عمليةٍ سليمة — ثم يعرض عطلًا لا وجود له. * EN: Writes the state, **and never throws**. This file is a display convenience; failing to write it * — a full disk, a permission — must never bring down a restore **midway** through a customer's * data. * * **The write is atomic: a temporary file, then a rename.** The reader is another process reading * whenever it likes, and a direct write exposes it to half a JSON document — read as "corrupt" * about a perfectly good operation, then displayed as a fault that does not exist. */ export declare function writeMaintenanceProgress(runDir: string, progress: MaintenanceProgress): void; /** يقرأ آخر حالة مكتوبة، أو ‎undefined‎ حين لا ملفّ — ولا يرمي على ملفٍّ تالف. */ export declare function readMaintenanceProgress(runDir: string): MaintenanceProgress | undefined; /** * AR: هل ثمّة عملية صيانةٍ تجري الآن؟ **دالّة نقيّة، وحياةُ العملية تُمرَّر إليها لا تُسأل داخلها.** * * والقرار له وجهان يجب أن يصدق كلاهما: خطأٌ في اتّجاهٍ يسمح لعمليتين أن تكتبا الشجرة معًا، * وخطأٌ في الاتّجاه الآخر يُقفل اللوحة إلى الأبد على عمليةٍ ماتت مع انقطاع الكهرباء. لذلك * يُختبَر الطرفان. * EN: Is a maintenance operation running right now? **A pure function, with the process's liveness * passed in rather than asked for inside.** * * The decision has two sides and both must hold: erring one way lets two operations write the * tree together, and erring the other locks the dashboard forever on an operation that died with * the power. So both sides are tested. */ export declare function isMaintenanceRunning(progress: MaintenanceProgress | undefined, alive: (pid: number) => boolean): boolean; /** ماذا يجري على الشجرة الآن — أو ‎undefined‎ حين لا شيء. */ export type TreeActivity = { kind: "maintenance"; operation: MaintenanceOperation; } | { kind: "update"; }; /** * AR: **القفل الواحد على الشجرة الواحدة.** يفحص الملفَّين معًا — الصيانة والتحديث — ويعيد ما يجري * أو ‎undefined‎. * * يناديه كلُّ من يوشك أن يكتب: المدخل المشحون قبل أيّ وضعٍ من أوضاعه الثلاثة، و‎runUpdate‎ * قبل أن يزيح مجلدًا، والنواة قبل أن تُطلق أيًّا منهما. وحارسٌ يعرف نصف ما يكتب الشجرة يترك * النصف الآخر يمرّ. * EN: **One lock on one tree.** Checks both files — maintenance and update — and returns what is * running, or `undefined`. * * Everything about to write calls it: the shipped entry before any of its three modes, * `runUpdate` before it moves a directory, and the core before it launches either. A guard that * knows half of what writes the tree lets the other half through. */ export declare function treeActivity(runDir: string, alive?: (pid: number) => boolean, self?: number): TreeActivity | undefined; /** جملةٌ إنجليزية تصف ما يجري — للسجلّ ولرسائل الرفض في الطرفية. */ export declare function describeActivity(activity: TreeActivity): string; //# sourceMappingURL=progress-file.d.ts.map