From 1c97ffb91bb4928022e995709d7e55b19cfd18eb Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 10 Oct 2026 15:50:39 +0200 Subject: feat(android): back up the files of folders the person chooses A Files section takes folders through the system picker (no storage permission), refuses DCIM, Pictures and Movies, skips what the photo backup sends, and runs on the photo backup's own runner into /-drive. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-hub/src/meshbay_hub/static/app.js | 48 +++++++++++++--------- 1 file changed, 28 insertions(+), 20 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/app.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js index 031e276..d8818d0 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js @@ -919,6 +919,19 @@ function App() { pullOnce(user.userId).catch(() => {}); }, [user, groups.length]); + // What every phone backup runs with: the live user and bundle key, read + // when a run starts, never ones captured here. + const backupContext = () => ({ + hub: HUB, + hubFetch, + getUser: () => userRef.current, + getBundleKey: async () => { + const key = session.bundleKey || await _loadBundleKey(); + if (key) session.bundleKey = key; + return key; + }, + }); + // Photo backup (docs/MESHBAY_DESIGN.md §9.12), on the Android application // only: loaded and started once signed in, stopped on sign-out. A run reads // the live user and bundle key when it starts, never ones captured here. @@ -929,21 +942,25 @@ function App() { let gone = false; import('./photo-sync.js').then((m) => { if (gone) return; - m.startPhotoSync({ - hub: HUB, - hubFetch, - getUser: () => userRef.current, - getBundleKey: async () => { - const key = session.bundleKey || await _loadBundleKey(); - if (key) session.bundleKey = key; - return key; - }, - }); + m.startPhotoSync(backupContext()); stop = m.stopPhotoSync; }).catch((e) => console.warn('[MeshBay] photo backup did not load:', e.message)); return () => { gone = true; if (stop) stop(); }; }, [syncAccount]); + // Files backup (§9.13), the same way. + useEffect(() => { + if (!syncAccount || !platform.driveSync.available) return undefined; + let stop = null; + let gone = false; + import('./drive-sync.js').then((m) => { + if (gone) return; + m.startDriveSync(backupContext()); + stop = m.stopDriveSync; + }).catch((e) => console.warn('[MeshBay] files backup did not load:', e.message)); + return () => { gone = true; if (stop) stop(); }; + }, [syncAccount]); + // Contacts, calendar and messages backup (§9.13), the same way. useEffect(() => { if (!syncAccount || !(platform.contactSync.available || platform.calendarSync.available @@ -954,16 +971,7 @@ function App() { let gone = false; import('./phone-sync.js').then((m) => { if (gone) return; - m.startPhoneSync({ - hub: HUB, - hubFetch, - getUser: () => userRef.current, - getBundleKey: async () => { - const key = session.bundleKey || await _loadBundleKey(); - if (key) session.bundleKey = key; - return key; - }, - }); + m.startPhoneSync(backupContext()); stop = m.stopPhoneSync; }).catch((e) => console.warn('[MeshBay] phone backups did not load:', e.message)); return () => { gone = true; if (stop) stop(); }; -- cgit v1.2.3