diff --git a/TODO.md b/TODO.md index f990715..2b7f631 100644 --- a/TODO.md +++ b/TODO.md @@ -2,13 +2,6 @@ ## Ideas -- Unstick a wrong salt: while a tracker share or search runs, the salt is locked, and a receiver - told "Check the code and the salt" can't change it for up to 6 minutes. The receiver doesn't need - the lock: like the code field, the salt could stay editable and count from the next Receive - (`saltLocked` only for `side === 'send'`). The sender does, the code shown must match the salt - shown: a Stop button next to the valid code would end the share, unlock the salt and also let a - share be withdrawn early. Changing the salt itself shouldn't end a share, a stray click would. - - Resume interrupted transfers: the receiver already reports how much the download manager has read (`{ read }`), which is where a new connection could continue. The browser can't append to a finished or failed download though, so a resume would have to start a new one. diff --git a/e2e.spec.ts b/e2e.spec.ts index 6508102..638e126 100644 --- a/e2e.spec.ts +++ b/e2e.spec.ts @@ -1180,7 +1180,7 @@ for (const name of Object.keys(BROWSERS)) { // The info_hash tells which salt a share took: the window its code ends with, or that and the own // salt, trimmed and NFC. A code made late in a window still lasts 6 minutes. The salt stays as it is - // while a share or search runs. + // while a share runs, a search lets it be fixed for the next Receive. test(`salt: ${name} a share takes the clock's salt or the own one, which stays while it runs`, async () => { const sender = await open(name); const hashes: string[] = []; @@ -1267,12 +1267,16 @@ for (const name of Object.keys(BROWSERS)) { await sender.fill('#receive-code', 'abcdefghijk'); await sender.click('#receive'); await expect.poll(() => hashes).toContain(swarm('abcdefghijk', generated)); - await locked(true); + await locked(false); + await sender.fill('#salt', 'fixed'); + await sender.click('#receive'); + await expect.poll(() => hashes).toContain(swarm('abcdefghijk', 'fixed')); }); }); - // Until the transfer is over, on both sides. - test(`salt: ${name} stays while the peers are connected`, async () => { + // On the sender until the transfer is over. The receiver's search is over once connected, so its + // salt can always change. + test(`salt: ${name} stays on the sender while the peers are connected`, async () => { const tracker = await ownTracker(); const [sender, receiver] = await Promise.all([open(name), open(name)]); for (const page of [sender, receiver]) { @@ -1282,9 +1286,9 @@ for (const name of Object.keys(BROWSERS)) { await page.check('#own-salt'); await page.fill('#salt', 'salt'); } - const locked = (disabled: boolean) => + const locked = (pages: Page[], disabled: boolean) => Promise.all( - [sender, receiver].flatMap((page) => + pages.flatMap((page) => ['#own-salt', '#salt', '#generate-salt'].map((id) => expect(page.locator(id)).toBeEnabled({ enabled: !disabled }), ), @@ -1295,14 +1299,15 @@ for (const name of Object.keys(BROWSERS)) { await connect('tracker', sender, receiver, await payload(randomBytes(1000))); await expect(sender.locator('#send-status')).toHaveText('Waiting for the receiver to download'); await expect(receiver.locator('#receive-status')).toHaveText('Click Download to save the file'); - await locked(true); + await locked([sender], true); + await locked([receiver], false); const started = downloadStarts(receiver); await receiver.click('#download'); await started; await expect(sender.locator('#send-status')).toHaveText('Delivered'); await expect(receiver.locator('#receive-status')).toHaveText('Download complete'); - await locked(false); + await locked([sender, receiver], false); }); }); diff --git a/src/App.vue b/src/App.vue index 5e1765a..eb1cc05 100644 --- a/src/App.vue +++ b/src/App.vue @@ -277,9 +277,12 @@ function onReceive() { attempt(signal, receiveViaTracker(receiveCode.value, receiveEvents, signal, salt())); } -// The salt stays as it is while a tracker share or search runs: it found or waits in the swarm of the -// salt it started with, another one shown would be the wrong one to give the receiver. -const saltLocked = computed(() => viaTracker.value && !['error', 'done', 'stopped'].includes(phase.value!)); +// The salt stays as it is while a tracker share runs: it waits in the swarm of the salt it started +// with, another one shown would be the wrong one to give the receiver. A search only takes the salt +// on Receive, so a wrong one can be fixed and searched with again. +const saltLocked = computed( + () => viaTracker.value && side.value === 'send' && !['error', 'done', 'stopped'].includes(phase.value!), +);