From ab959cd85865c3fc31baff0996bb54318d10af15 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 22 Dec 2016 10:00:40 -0500 Subject: [PATCH] Fix "Reset File Sync History" --- chrome/content/zotero/preferences/preferences_sync.js | 4 ++-- chrome/content/zotero/xpcom/storage/storageLocal.js | 3 +-- test/tests/storageLocalTest.js | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_sync.js b/chrome/content/zotero/preferences/preferences_sync.js index 6196ae604..0eaf35a7d 100644 --- a/chrome/content/zotero/preferences/preferences_sync.js +++ b/chrome/content/zotero/preferences/preferences_sync.js @@ -408,7 +408,7 @@ Zotero_Preferences.Sync = { var newEnabled = document.getElementById('pref-storage-enabled').value; if (oldProtocol != newProtocol) { - yield Zotero.Sync.Storage.Local.resetModeSyncStates(oldProtocol); + yield Zotero.Sync.Storage.Local.resetAllSyncStates(); } if (oldProtocol == 'webdav') { @@ -751,7 +751,7 @@ Zotero_Preferences.Sync = { switch (index) { case 0: - Zotero.Sync.Storage.resetAllSyncStates(); + yield Zotero.Sync.Storage.Local.resetAllSyncStates(); ps.alert( null, "File Sync History Cleared", diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js index 2208b8852..8889d1ccc 100644 --- a/chrome/content/zotero/xpcom/storage/storageLocal.js +++ b/chrome/content/zotero/xpcom/storage/storageLocal.js @@ -500,7 +500,7 @@ Zotero.Sync.Storage.Local = { * This is used when switching between storage modes in the preferences so that all existing files * are uploaded via the new mode if necessary. */ - resetModeSyncStates: Zotero.Promise.coroutine(function* () { + resetAllSyncStates: Zotero.Promise.coroutine(function* () { var sql = "SELECT itemID FROM items JOIN itemAttachments USING (itemID) " + "WHERE libraryID=? AND itemTypeID=? AND linkMode IN (?, ?)"; var params = [ @@ -514,7 +514,6 @@ Zotero.Sync.Storage.Local = { let item = Zotero.Items.get(itemID); item._attachmentSyncState = this.SYNC_STATE_TO_UPLOAD; } - sql = "UPDATE itemAttachments SET syncState=? WHERE itemID IN (" + sql + ")"; yield Zotero.DB.queryAsync(sql, [this.SYNC_STATE_TO_UPLOAD].concat(params)); }), diff --git a/test/tests/storageLocalTest.js b/test/tests/storageLocalTest.js index 024e55e7f..bf3ac39c5 100644 --- a/test/tests/storageLocalTest.js +++ b/test/tests/storageLocalTest.js @@ -102,14 +102,14 @@ describe("Zotero.Sync.Storage.Local", function () { }) }) - describe("#resetModeSyncStates()", function () { + describe("#resetAllSyncStates()", function () { it("should reset attachment sync states to 'to_upload'", function* () { var attachment = yield importFileAttachment('test.png'); attachment.attachmentSyncState = 'in_sync'; yield attachment.saveTx(); var local = Zotero.Sync.Storage.Local; - yield local.resetModeSyncStates() + yield local.resetAllSyncStates() assert.strictEqual(attachment.attachmentSyncState, local.SYNC_STATE_TO_UPLOAD); var state = yield Zotero.DB.valueQueryAsync( "SELECT syncState FROM itemAttachments WHERE itemID=?", attachment.id