From 020cf3ee955d9b4f6815b0b18fba29fa4d88f683 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 27 Nov 2009 21:39:11 +0000 Subject: [PATCH] Try to fix Windows file access error on syncing of modified files --- chrome/content/zotero/xpcom/storage.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index cd23c3da29..195fc600e1 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1050,9 +1050,10 @@ Zotero.Sync.Storage = new function () { // Delete existing files var otherFiles = parentDir.directoryEntries; - while (otherFiles.hasMoreElements()) { - var file = otherFiles.getNext(); - file.QueryInterface(Components.interfaces.nsIFile); + otherFiles.QueryInterface(Components.interfaces.nsIDirectoryEnumerator); + var filesToDelete = []; + var file; + while (file = otherFiles.nextFile) { if (file.leafName[0] == '.') { continue; } @@ -1076,6 +1077,12 @@ Zotero.Sync.Storage = new function () { continue; } + filesToDelete.push(file); + } + otherFiles.close(); + + // Do deletes outside of the enumerator to avoid an access error on Windows + for each(var file in filesToDelete) { if (file.isFile()) { Zotero.debug("Deleting existing file " + file.leafName); try {