From f829d7c43e3c0fe28592c9bd439db096c598cf79 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 17 Jun 2024 01:18:14 -0400 Subject: [PATCH] Explicitly close file input stream at end of md5Async() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes "Could not remove the non-empty directory at…" file-sync error on Windows Fixes #4246 --- chrome/content/zotero/xpcom/utilities_internal.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index 686a30aeab..142d06b13f 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -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(); + } },