mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-08 15:10:54 +03:00
changed to handle 404 during download, also removing progress listener once percent completion is 100 to avoid manipulating DOM twice
This commit is contained in:
@@ -15,6 +15,8 @@ let download = () => {
|
||||
progress.innerText = `Progress: ${percentComplete}%`;
|
||||
|
||||
if (percentComplete === 100) {
|
||||
fileReceiver.removeAllListeners('progress');
|
||||
|
||||
let finished = document.createElement('p');
|
||||
finished.innerText = 'Your download has finished.';
|
||||
li.appendChild(finished);
|
||||
@@ -28,7 +30,13 @@ let download = () => {
|
||||
}
|
||||
});
|
||||
|
||||
fileReceiver.download().then(([decrypted, fname]) => {
|
||||
fileReceiver.download()
|
||||
.catch((err) => {
|
||||
console.log('The file has expired, or has already been deleted.');
|
||||
document.getElementById('downloaded_files').removeChild(li);
|
||||
return;
|
||||
})
|
||||
.then(([decrypted, fname]) => {
|
||||
name.innerText = fname;
|
||||
let dataView = new DataView(decrypted);
|
||||
let blob = new Blob([dataView]);
|
||||
|
||||
Reference in New Issue
Block a user