diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-10-10 12:56:26 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-10-10 12:56:26 +0200 |
| commit | a0793dd37030f7213ecb07a018b11e6a8adf9238 (patch) | |
| tree | 5de1046eae9b3747ac97a81652590fb6af99622b /packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js | |
| parent | 044c585f73cfd548e300859e89eaf5dcb40d3d3c (diff) | |
| download | meshbay-a0793dd37030f7213ecb07a018b11e6a8adf9238.tar.gz | |
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
<folder>/<account>-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 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/static/photo-sync.js | 13 |
1 files changed, 8 insertions, 5 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 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) { } /** `<folder>/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}`; |