commit 0d008b4704ccf1e09e287a12311a932a23f5436e
parent 88a43fea31a619a166f1e5aa035a269575d1734f
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 2 Jun 2016 03:40:01 -0400
Use OS.File.removeDir() to delete existing attachment files during sync
Diffstat:
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
@@ -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);
}),