parrot-blackbox 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/backup/urgent.js +24 -2
- package/src/cli.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parrot-blackbox",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Crash-proof, multi-cloud backup & recovery automation for Parrot OS. Daily/weekly off-disk backups with automatic catch-up, smart storage across many MEGA + Google Drive accounts, Timeshift snapshot backups and one-command restore.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/cli.js",
|
package/src/backup/urgent.js
CHANGED
|
@@ -103,8 +103,25 @@ export function buildUrgentBundle({ home = process.env.HOME } = {}) {
|
|
|
103
103
|
*/
|
|
104
104
|
export async function runUrgentBackup(cfg = loadConfig(), state = loadState(), { onProgress } = {}) {
|
|
105
105
|
const now = clock();
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
|
|
107
|
+
// ── Resume an interrupted upload ─────────────────────────────────────────
|
|
108
|
+
// If a previous urgent upload died mid-transfer (power cut / crash / Ctrl+C),
|
|
109
|
+
// a pending marker was persisted in state BEFORE any long work began. On the
|
|
110
|
+
// next run we REUSE that id so `planAndPlace` writes back into the SAME cloud
|
|
111
|
+
// directory — rclone copy is per-file idempotent, so already-uploaded files
|
|
112
|
+
// are skipped and only the remainder is transferred, then the manifest is
|
|
113
|
+
// rewritten once the last file lands. The bundle itself is regenerated (the
|
|
114
|
+
// staging dir is transient), which is fine because the sources are fixed.
|
|
115
|
+
const resumed = Boolean(state.urgentPending?.id);
|
|
116
|
+
const id = resumed ? state.urgentPending.id : iso(now);
|
|
117
|
+
if (!resumed) {
|
|
118
|
+
state.urgentPending = { id, since: iso(now) };
|
|
119
|
+
saveState(state); // persist the marker before any long work → crash-safe
|
|
120
|
+
journal('urgent', `start id=${id}`);
|
|
121
|
+
} else {
|
|
122
|
+
journal('urgent', `resume id=${id} (previous upload was interrupted)`);
|
|
123
|
+
}
|
|
124
|
+
|
|
108
125
|
const bundle = buildUrgentBundle();
|
|
109
126
|
|
|
110
127
|
const accounts = await refreshAccounts(cfg);
|
|
@@ -134,11 +151,16 @@ export async function runUrgentBackup(cfg = loadConfig(), state = loadState(), {
|
|
|
134
151
|
totalSize: manifest.totalSize,
|
|
135
152
|
entryCount: manifest.entries?.length || 0,
|
|
136
153
|
};
|
|
154
|
+
// Only clear the pending marker once the upload FULLY landed (manifest is on
|
|
155
|
+
// the cloud + mirrored locally). If we crash before this line, the next run
|
|
156
|
+
// resumes the same id — re-copying is a no-op for finished files.
|
|
157
|
+
delete state.urgentPending;
|
|
137
158
|
saveState(state);
|
|
138
159
|
journal('urgent', `done id=${id} bytes=${manifest.totalSize}`);
|
|
139
160
|
|
|
140
161
|
return {
|
|
141
162
|
id,
|
|
163
|
+
resumed,
|
|
142
164
|
manifest,
|
|
143
165
|
sizeBytes: manifest.totalSize,
|
|
144
166
|
skippedRepos: bundle.skippedRepos,
|
package/src/cli.js
CHANGED
|
@@ -423,7 +423,7 @@ const main = defineCommand({
|
|
|
423
423
|
try {
|
|
424
424
|
const r = await runUrgentBackup(undefined, undefined, { onProgress: progress });
|
|
425
425
|
progress.stop();
|
|
426
|
-
console.log(`${pc.green('✔')} Urgent backup stored (${bytesHuman(r.sizeBytes)}). Restore with: \`parrot-blackbox restore urgent\`.`);
|
|
426
|
+
console.log(`${pc.green('✔')} Urgent backup ${r.resumed ? 'resumed & ' : ''}stored (${bytesHuman(r.sizeBytes)}). Restore with: \`parrot-blackbox restore urgent\`.`);
|
|
427
427
|
if (r.skippedRepos?.length) console.log(pc.dim(`Skipped ${r.skippedRepos.length} git-tracked folder(s).`));
|
|
428
428
|
if (r.missing?.length) console.log(pc.dim(`Source(s) not present, skipped: ${r.missing.join(', ')}.`));
|
|
429
429
|
} catch (e) {
|