From 0d008b4704ccf1e09e287a12311a932a23f5436e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 2 Jun 2016 03:40:01 -0400 Subject: [PATCH] Use OS.File.removeDir() to delete existing attachment files during sync --- .../zotero/xpcom/storage/storageLocal.js | 33 ++----------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index d3ba98a62..dd6146d6d 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -894,38 +894,9 @@ Zotero.Sync.Storage.Local = { }), - _deleteExistingAttachmentFiles: Zotero.Promise.coroutine(function* (item) { + _deleteExistingAttachmentFiles: Zotero.Promise.method(function (item) { var parentDir = Zotero.Attachments.getStorageDirectory(item).path; - return this._deleteExistingFilesInDirectory(parentDir); - }), - - - _deleteExistingFilesInDirectory: Zotero.Promise.coroutine(function* (dir) { - var dirsToDelete = []; - var iterator = new OS.File.DirectoryIterator(dir); - try { - yield iterator.forEach(function (entry) { - return Zotero.Promise.coroutine(function* () { - if (entry.isDir) { - dirsToDelete.push(entry.path); - } - else { - try { - yield OS.File.remove(entry.path); - } - catch (e) { - Zotero.File.checkFileAccessError(e, entry.path, 'delete'); - } - } - })(); - }); - } - finally { - iterator.close(); - } - for (let path of dirsToDelete) { - yield this._deleteExistingFilesInDirectory(path); - } + return OS.File.removeDir(parentDir); }),