Let the receiver fix a wrong salt during a search
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2e47b55901
commit
aa61efcc10
3 files changed
+19
-18
No files matched your search
@@ -2,13 +2,6 @@
|
|||||||
|
|
||||||
## Ideas
|
## 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
|
- 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
|
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.
|
finished or failed download though, so a resume would have to start a new one.
|
||||||
|
|||||||
+13
-8
@@ -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
|
// 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
|
// 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 () => {
|
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 sender = await open(name);
|
||||||
const hashes: string[] = [];
|
const hashes: string[] = [];
|
||||||
@@ -1267,12 +1267,16 @@ for (const name of Object.keys(BROWSERS)) {
|
|||||||
await sender.fill('#receive-code', 'abcdefghijk');
|
await sender.fill('#receive-code', 'abcdefghijk');
|
||||||
await sender.click('#receive');
|
await sender.click('#receive');
|
||||||
await expect.poll(() => hashes).toContain(swarm('abcdefghijk', generated));
|
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.
|
// On the sender until the transfer is over. The receiver's search is over once connected, so its
|
||||||
test(`salt: ${name} stays while the peers are connected`, async () => {
|
// salt can always change.
|
||||||
|
test(`salt: ${name} stays on the sender while the peers are connected`, async () => {
|
||||||
const tracker = await ownTracker();
|
const tracker = await ownTracker();
|
||||||
const [sender, receiver] = await Promise.all([open(name), open(name)]);
|
const [sender, receiver] = await Promise.all([open(name), open(name)]);
|
||||||
for (const page of [sender, receiver]) {
|
for (const page of [sender, receiver]) {
|
||||||
@@ -1282,9 +1286,9 @@ for (const name of Object.keys(BROWSERS)) {
|
|||||||
await page.check('#own-salt');
|
await page.check('#own-salt');
|
||||||
await page.fill('#salt', 'salt');
|
await page.fill('#salt', 'salt');
|
||||||
}
|
}
|
||||||
const locked = (disabled: boolean) =>
|
const locked = (pages: Page[], disabled: boolean) =>
|
||||||
Promise.all(
|
Promise.all(
|
||||||
[sender, receiver].flatMap((page) =>
|
pages.flatMap((page) =>
|
||||||
['#own-salt', '#salt', '#generate-salt'].map((id) =>
|
['#own-salt', '#salt', '#generate-salt'].map((id) =>
|
||||||
expect(page.locator(id)).toBeEnabled({ enabled: !disabled }),
|
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 connect('tracker', sender, receiver, await payload(randomBytes(1000)));
|
||||||
await expect(sender.locator('#send-status')).toHaveText('Waiting for the receiver to download');
|
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 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);
|
const started = downloadStarts(receiver);
|
||||||
await receiver.click('#download');
|
await receiver.click('#download');
|
||||||
await started;
|
await started;
|
||||||
await expect(sender.locator('#send-status')).toHaveText('Delivered');
|
await expect(sender.locator('#send-status')).toHaveText('Delivered');
|
||||||
await expect(receiver.locator('#receive-status')).toHaveText('Download complete');
|
await expect(receiver.locator('#receive-status')).toHaveText('Download complete');
|
||||||
await locked(false);
|
await locked([sender, receiver], false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -277,9 +277,12 @@ function onReceive() {
|
|||||||
attempt(signal, receiveViaTracker(receiveCode.value, receiveEvents, signal, salt()));
|
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
|
// The salt stays as it is while a tracker share runs: it waits in the swarm of the salt it started
|
||||||
// salt it started with, another one shown would be the wrong one to give the receiver.
|
// with, another one shown would be the wrong one to give the receiver. A search only takes the salt
|
||||||
const saltLocked = computed(() => viaTracker.value && !['error', 'done', 'stopped'].includes(phase.value!));
|
// 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!),
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
Reference in new issue
Block a user