From a0793dd37030f7213ecb07a018b11e6a8adf9238 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Sat, 10 Oct 2026 12:56:26 +0200 Subject: feat(android): back the phone's contacts up to a group of one's own A Contacts backup section on the Android Sync page sends a dated .vcf into /-contacts once a day when the address book changed, only to a group the account is alone in, checked again at every run. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js') 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 74084b8..77d050e 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js @@ -229,8 +229,11 @@ async function send(transport, cfg, items, metered) { setState({ phase: 'up_to_date', done, total: items.length }); } -/** One photo, under a slot the node granted — the backup queues like anyone. */ -async function upload(transport, item) { +/** + * One photo, under a slot the node granted: the backup queues like anyone. + * `file` is how its bytes come from the phone; contacts and messages pass theirs. + */ +export async function upload(transport, item, file = platform.photoSync.file) { const lease = transport.openTransfer({ kind: 'upload', bytes: item.size }); try { let timeout; @@ -240,8 +243,8 @@ async function upload(transport, item) { timeout = setTimeout(() => reject(new Error('The node is busy')), LEASE_WAIT_MS); }), ]).finally(() => clearTimeout(timeout)); - const file = await platform.photoSync.file(item.token, item.name); - return await transport.uploadFile(file, { + const bytes = await file(item.token, item.name); + return await transport.uploadFile(bytes, { dir: item.dir, root: item.dir.split('/')[0], tr: lease.tr, }); } finally { @@ -250,7 +253,7 @@ async function upload(transport, item) { } /** `/YYYY/YYYY-MM`, one level at a time; a level that exists is fine. */ -async function makeDirs(transport, folder, dir, dirs) { +export async function makeDirs(transport, folder, dir, dirs) { let at = folder; for (const name of dir.slice(folder.length + 1).split('/').filter(Boolean)) { const next = `${at}/${name}`; -- cgit v1.2.3