mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-29 19:19:14 -04:00
Delete files from OPFS when user closes the ReceiveFileDialog
This commit is contained in:
parent
490bad5734
commit
50539ed485
1 changed files with 15 additions and 4 deletions
|
@ -1306,8 +1306,6 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
|
|
||||||
Events.fire('notify-user', downloadSuccessfulTranslation);
|
Events.fire('notify-user', downloadSuccessfulTranslation);
|
||||||
this.downloadSuccessful = true;
|
this.downloadSuccessful = true;
|
||||||
|
|
||||||
this.hide();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,8 +1333,6 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
|
|
||||||
Events.fire('notify-user', downloadSuccessfulTranslation);
|
Events.fire('notify-user', downloadSuccessfulTranslation);
|
||||||
this.downloadSuccessful = true;
|
this.downloadSuccessful = true;
|
||||||
|
|
||||||
this.hide();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1400,6 +1396,7 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
this.$downloadBtn.removeAttribute('disabled');
|
this.$downloadBtn.removeAttribute('disabled');
|
||||||
this.$downloadBtn.removeAttribute('hidden');
|
this.$downloadBtn.removeAttribute('hidden');
|
||||||
|
|
||||||
|
// Todo: complete rewrite of the download button logic and file zipping
|
||||||
let {sendAsZip, zipObjectUrl, zipName} = await this._processDataAsZip();
|
let {sendAsZip, zipObjectUrl, zipName} = await this._processDataAsZip();
|
||||||
|
|
||||||
// If single file or zipping failed or file size exceeds memory -> download files individually -> else download zip
|
// If single file or zipping failed or file size exceeds memory -> download files individually -> else download zip
|
||||||
|
@ -1438,6 +1435,16 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
this.$previewBox.innerHTML = '';
|
this.$previewBox.innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _deleteFilesFromDisk(files) {
|
||||||
|
for(const file of files) {
|
||||||
|
if (!file.id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let fileId = await SWFileDigester.deleteFileById(file.id)
|
||||||
|
Logger.log(`File with id: ${fileId} successfully deleted.`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hide() {
|
hide() {
|
||||||
super.hide();
|
super.hide();
|
||||||
|
|
||||||
|
@ -1445,6 +1452,10 @@ class ReceiveFileDialog extends ReceiveDialog {
|
||||||
this._tidyUpButtons();
|
this._tidyUpButtons();
|
||||||
this._tidyUpPreviewBox();
|
this._tidyUpPreviewBox();
|
||||||
|
|
||||||
|
let oldFiles = this._data.files;
|
||||||
|
this._deleteFilesFromDisk(oldFiles)
|
||||||
|
.then(() => Logger.log("Deletion of old files finished."))
|
||||||
|
|
||||||
this._busy = false;
|
this._busy = false;
|
||||||
|
|
||||||
await this._processFiles();
|
await this._processFiles();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue