aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/transport.js
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-15 22:55:25 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-15 22:55:25 +0200
commit1f84c047914cf21df1a1de196d990d193539523d (patch)
treea818f18127af96349b6f3da8c53212c324672b60 /packages/meshbay-hub/src/meshbay_hub/static/transport.js
parent459fc93e98f23e326c2fa77fe86ba74c2bae77f0 (diff)
downloadmeshbay-1f84c047914cf21df1a1de196d990d193539523d.tar.gz
feat(hub): drop files and folders onto Files to upload them
Into the folder on screen, under the Upload button's rule. A name already there, or one the node would refuse, cancels the whole drop with a message. Folders are recreated level by level; files go out a few at a time. The in-flight upload guard is keyed by folder and name. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/transport.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/transport.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
index 1f05b8d..77bf522 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
@@ -2329,15 +2329,17 @@ class MeshBayTransport {
async uploadFile(file, { chunkSize, onProgress, signal, root, dir,
tr = '' } = {}) {
// The same file twice at once would confuse the node, which keys its own
- // upload state by name — and would race for the same destination. The guard
- // is by name for that reason, even though the map below is keyed by id.
- if (this._inFlightUploads.has(file.name)) {
+ // upload state by folder and name — and would race for the same
+ // destination. The guard uses the same key: by name alone, a dropped folder
+ // holding a `cover.jpg` in two albums failed the second one for nothing.
+ const inFlightKey = `${dir || ''}/${file.name}`;
+ if (this._inFlightUploads.has(inFlightKey)) {
throw new Error(`${file.name} is already being uploaded`);
}
if (!this._gekRaw) throw new Error('This group has no key on this device');
const C = window.MeshBayCrypto;
const groupId = (this._connectArgs && this._connectArgs.groupId) || '';
- this._inFlightUploads.add(file.name);
+ this._inFlightUploads.add(inFlightKey);
const uploadId = _hex(crypto.getRandomValues(new Uint8Array(16)));
const size = chunkSize || UPLOAD_CHUNK_SIZE;
const total = Math.max(1, Math.ceil(file.size / size));
@@ -2487,7 +2489,7 @@ class MeshBayTransport {
}
} finally {
this._uploaders.delete(uploadId);
- this._inFlightUploads.delete(file.name);
+ this._inFlightUploads.delete(inFlightKey);
}
return stored || {};
}