Finish dictionary installation even if file cleanup fails (on Windows)

This commit is contained in:
Martynas Bagdonas 2024-03-19 11:59:18 +02:00
parent aef07afd32
commit a50b7ef04a

View file

@ -136,20 +136,11 @@ Zotero.Dictionaries = new function () {
}
zipReader.close();
zipReader = null
zipReader = null;
Cu.forceGC();
await OS.File.remove(xpiPath);
await _loadDirectory(dir);
}
catch (e) {
try {
if (await OS.File.exists(xpiPath)) {
await OS.File.remove(xpiPath);
}
}
catch (e) {
Zotero.logError(e);
}
try {
if (await OS.File.exists(dir)) {
await OS.File.removeDir(dir);
@ -160,6 +151,19 @@ Zotero.Dictionaries = new function () {
}
throw e;
}
finally {
// Remove the downloaded file from the temp path
// Note: In same cases, on Windows, it can't be removed
// because something is keeping it open
try {
if (await OS.File.exists(xpiPath)) {
await OS.File.remove(xpiPath);
}
}
catch (e) {
Zotero.logError(e);
}
}
};
/**