Explicitly close file input stream at end of md5Async()

Fixes "Could not remove the non-empty directory at…" file-sync error on
Windows

Fixes #4246
This commit is contained in:
Dan Stillman 2024-06-17 01:18:14 -04:00
parent f7d7625c1c
commit f829d7c43e

View file

@ -165,9 +165,9 @@ Zotero.Utilities.Internal = {
.createInstance(Components.interfaces.nsICryptoHash);
ch.init(ch.MD5);
var is = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
try {
let is = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
is.init(Zotero.File.pathToFile(file), -1, -1, Ci.nsIFileInputStream.CLOSE_ON_EOF);
ch.updateFromStream(is, -1);
// Get binary string and convert to hex string
@ -187,6 +187,9 @@ Zotero.Utilities.Internal = {
}
throw e;
}
finally {
is.close();
}
},