Merge remote-tracking branch 'origin/master' into vnext
This commit is contained in:
commit
f923ff4f87
3 changed files with 19 additions and 3 deletions
|
@ -225,7 +225,6 @@ function download(id, keychain, onprogress, canceller) {
|
||||||
const auth = await keychain.authHeader();
|
const auth = await keychain.authHeader();
|
||||||
xhr.open('get', `/api/download/${id}`);
|
xhr.open('get', `/api/download/${id}`);
|
||||||
xhr.setRequestHeader('Authorization', auth);
|
xhr.setRequestHeader('Authorization', auth);
|
||||||
xhr.setRequestHeader('Connection', 'close');
|
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
xhr.send();
|
xhr.send();
|
||||||
onprogress([0, 1]);
|
onprogress([0, 1]);
|
||||||
|
|
|
@ -21,10 +21,11 @@ module.exports = async function(req, res) {
|
||||||
file_stream.destroy();
|
file_stream.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
file_stream.on('close', async () => {
|
file_stream.on('end', async () => {
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dl = meta.dl + 1;
|
const dl = meta.dl + 1;
|
||||||
const dlimit = meta.dlimit;
|
const dlimit = meta.dlimit;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -134,7 +134,23 @@ describe('Upload / Download flow', function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can cancel and not increase download count', async function() {
|
it('can increase download count on download', async function() {
|
||||||
|
const fs = new FileSender(blob);
|
||||||
|
const file = await fs.upload();
|
||||||
|
const fr = new FileReceiver({
|
||||||
|
secretKey: file.toJSON().secretKey,
|
||||||
|
id: file.id,
|
||||||
|
nonce: file.keychain.nonce,
|
||||||
|
requiresPassword: false
|
||||||
|
});
|
||||||
|
await fr.getMetadata();
|
||||||
|
|
||||||
|
await fr.download(noSave);
|
||||||
|
await file.updateDownloadCount();
|
||||||
|
assert.equal(file.dtotal, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not increase download count when download cancelled', async function() {
|
||||||
const fs = new FileSender(blob);
|
const fs = new FileSender(blob);
|
||||||
const file = await fs.upload();
|
const file = await fs.upload();
|
||||||
const fr = new FileReceiver({
|
const fr = new FileReceiver({
|
||||||
|
|
Loading…
Reference in a new issue