Fix "Reset File Sync History"
This commit is contained in:
parent
cf686c520a
commit
ab959cd858
3 changed files with 5 additions and 6 deletions
|
@ -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",
|
||||
|
|
|
@ -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));
|
||||
}),
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue