aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-10 16:15:48 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-10 16:15:48 +0200
commit24547e4efd3a45b36b3bea8c29cfc687230a6d3a (patch)
tree05aed558b665841230b0a1b4d2f987091c573ab8 /packages/meshbay-hub/src/meshbay_hub/static
parent1c97ffb91bb4928022e995709d7e55b19cfd18eb (diff)
downloadmeshbay-24547e4efd3a45b36b3bea8c29cfc687230a6d3a.tar.gz
feat(android): send a manifest of what each backup run sent
Photos, videos and files record, per file, their path on the node, their path and album on the phone, dates, size and SHA-256, uploaded as meshbay-manifest/manifest-<date>.jsonl once the run is done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js23
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/platform.js4
2 files changed, 25 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js b/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
index 1439c20..a9d4517 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js
@@ -172,8 +172,8 @@ export function createBackup({
if (refused === 'offline') { setState({ phase: 'offline' }); return; }
if (refused) { await lasting(refused); return; }
- const { items } = await sync.plan();
- if (!items.length) {
+ const { items, manifest } = await sync.plan();
+ if (!items.length && !manifest) {
await sync.completed();
setState({ phase: 'up_to_date', done: 0, total: 0 });
return;
@@ -246,10 +246,29 @@ export function createBackup({
done += 1;
await sync.keepAlive(true, report());
}
+ if (!await sendManifest(transport, dest, dirs)) return;
await sync.completed();
setState({ phase: 'up_to_date', done, total: items.length });
}
+ // What the phone knew of what was sent (its path and album, its dates and
+ // hash), for a restore or a merge later: one file per run that sent
+ // anything, beside the files, kept by the phone until the node has it.
+ // False when a lasting refusal stopped it, which is then said.
+ async function sendManifest(transport, dest, dirs) {
+ const { item } = await sync.manifest();
+ if (!item) return true;
+ try {
+ await makeDirs(transport, dest.folder, item.dir, dirs);
+ await upload(transport, item, sync.file);
+ } catch (e) {
+ if (e.code && failures[e.code]) { await lasting(e.code); return false; }
+ throw e;
+ }
+ await sync.manifestSent(item.token);
+ return true;
+ }
+
async function lasting(code) {
setState({ phase: 'failed', reason: code });
await sync.failed(code, say(code)).catch(() => {});
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
index 04e26e6..b1a8ae9 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
@@ -244,6 +244,8 @@ export const photoSync = {
estimate(settings) { return bridge.photoSync.estimate(settings); },
plan() { return bridge.photoSync.plan(); },
sent(token, dir, name) { return bridge.photoSync.sent(token, dir, name); },
+ manifest() { return bridge.photoSync.manifest(); },
+ manifestSent(token) { return bridge.photoSync.manifestSent(token); },
completed() { return bridge.photoSync.completed(); },
failed(code, text) { return bridge.photoSync.failed(code, text); },
keepAlive(on, text) { return bridge.photoSync.keepAlive(on, text); },
@@ -285,6 +287,8 @@ export const driveSync = {
configure(settings) { return driveBridge.configure(settings); },
plan() { return driveBridge.plan(); },
sent(token, dir, name) { return driveBridge.sent(token, dir, name); },
+ manifest() { return driveBridge.manifest(); },
+ manifestSent(token) { return driveBridge.manifestSent(token); },
completed() { return driveBridge.completed(); },
failed(code, text) { return driveBridge.failed(code, text); },
keepAlive(on, text) { return driveBridge.keepAlive(on, text); },