www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit d106fc0313ce20a45fd69b6aef9bf6a5e8902bb9
parent 9c8738dca09fc43b2f3e5933a2d017953ac58f85
Author: Dan Stillman <dstillman@zotero.org>
Date:   Wed, 15 Jul 2009 07:27:53 +0000

- Add "Reset File Sync History" reset option to sync preferences
- Fix erroneous uploading of all files on storage history reset
- Fix re-verification of storage server after every opening of the preferences



Diffstat:
Mchrome/content/zotero/overlay.js | 1+
Mchrome/content/zotero/overlay.xul | 2+-
Mchrome/content/zotero/preferences/preferences.js | 31++++++++++++++++++++++++++++++-
Mchrome/content/zotero/preferences/preferences.xul | 42++++++++++++++++++++++++++++++++----------
Mchrome/content/zotero/xpcom/storage.js | 45++++++++++++++++++++++-----------------------
Mchrome/skin/default/zotero/preferences.css | 4+---
6 files changed, 87 insertions(+), 38 deletions(-)

diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js @@ -231,6 +231,7 @@ var ZoteroPane = new function() sep.nextSibling.nextSibling.hidden = false; sep.nextSibling.nextSibling.nextSibling.hidden = false; sep.nextSibling.nextSibling.nextSibling.nextSibling.hidden = false; + sep.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.hidden = false; } if (Zotero.Prefs.get('debugShowDuplicates')) { diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul @@ -142,7 +142,7 @@ <menuitem hidden="true" label=" Reset Server Lock" oncommand="Zotero.Sync.Server.resetServer()"/> <menuitem hidden="true" label=" Reset Client" oncommand="Zotero.Sync.Server.resetClient()"/> <menuitem label="Storage Debugging" disabled="true"/> - <menuitem label=" Reset Storage History" oncommand="Zotero.Sync.Storage.resetAllSyncStates()"/> + <menuitem hidden="true" label=" Reset Storage History" oncommand="Zotero.Sync.Storage.resetAllSyncStates()"/> <menuitem label=" Purge Deleted Storage Files" oncommand="Zotero.Sync.Storage.purgeDeletedStorageFiles(function(results) { Zotero.debug(results); })"/> <menuitem label=" Purge Orphaned Storage Files" oncommand="Zotero.Sync.Storage.purgeOrphanedStorageFiles(function(results) { Zotero.debug(results); })"/> <menuseparator id="zotero-tb-actions-separator"/> diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js @@ -194,7 +194,6 @@ function updateStorageSettings(value) { prefix.value = 'https://'; break; } - unverifyStorageServer(); } function unverifyStorageServer() { @@ -415,6 +414,36 @@ function handleSyncReset(action) { break; + case 'reset-storage-history': + var buttonFlags = (pr.BUTTON_POS_0) * (pr.BUTTON_TITLE_IS_STRING) + + (pr.BUTTON_POS_1) * (pr.BUTTON_TITLE_CANCEL) + + pr.BUTTON_POS_1_DEFAULT; + var index = pr.confirmEx( + // TODO: localize + Zotero.getString('general.warning'), + "All file sync history will be cleared.\n\n" + + "Any local attachment files that do not exist on the storage server will be uploaded on the next sync.", + buttonFlags, + "Reset", + null, null, null, {} + ); + + switch (index) { + case 0: + Zotero.Sync.Storage.resetAllSyncStates(); + pr.alert( + "File Sync History Cleared", + "The file sync history has been cleared." + ); + break; + + // Cancel + case 1: + return; + } + + break; + default: throw ("Invalid action '" + action + "' in handleSyncReset()"); } diff --git a/chrome/content/zotero/preferences/preferences.xul b/chrome/content/zotero/preferences/preferences.xul @@ -274,7 +274,7 @@ To add a new preference: <hbox> <menulist id="storage-url-protocol" preference="pref-storage-protocol" - onsynctopreference="updateStorageSettings(this.value)"> + onsynctopreference="updateStorageSettings(this.value); unverifyStorageServer();"> <menupopup> <menuitem label="WebDAV" value="webdav"/> <!-- TODO: localize --> @@ -330,10 +330,11 @@ To add a new preference: </tabpanel> <tabpanel id="zotero-reset" orient="vertical"> - <groupbox> - <caption label="Zotero Sync Server"/> - - <radiogroup id="zotero-reset-sync-group" oncommand="handleSyncResetSelect(this);"> + <radiogroup id="zotero-reset-sync-group" oncommand="handleSyncResetSelect(this)"> + <groupbox> + <!-- TODO: localize --> + <caption label="Zotero Sync Server"/> + <grid> <columns> <column/> @@ -366,12 +367,33 @@ To add a new preference: </row> </rows> </grid> - </radiogroup> + </groupbox> - <hbox> - <button id="zotero-reset-button" label="Reset..." oncommand="handleSyncReset(document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7))"/> - </hbox> - </groupbox> + <groupbox> + <caption label="Storage Server"/> + + <grid> + <columns> + <column/> + <column align="start" pack="start" flex="1"/> + </columns> + + <rows> + <row id="zotero-reset-storage-history"> + <radio/> + <vbox onclick="this.previousSibling.click()"> + <label value="Reset File Sync History"/> + <description>Force checking of the storage server for all local attachment files.</description> + </vbox> + </row> + </rows> + </grid> + </groupbox> + </radiogroup> + + <hbox> + <button id="zotero-reset-button" label="Reset..." oncommand="handleSyncReset(document.getElementById('zotero-reset-sync-group').selectedItem.parentNode.id.substr(7))"/> + </hbox> </tabpanel> </tabpanels> </tabbox> diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js @@ -1291,37 +1291,36 @@ Zotero.Sync.Storage = new function () { if (mdate) { var mtime = Zotero.Date.toUnixTimestamp(mdate); var smtime = Zotero.Sync.Storage.getSyncedModificationTime(item.id); - // File has been uploaded to storage server but there's - // no local record of the time (e.g., due to a reset), + // If file has been uploaded to storage server but there's + // no local record of the time (e.g., due to a reset?), // use local file's time if (!smtime) { smtime = item.attachmentModificationTime; - if (smtime == mtime) { - Zotero.debug("Stored file mod time matches remote file -- skipping upload"); - - Zotero.DB.beginTransaction(); - var syncState = Zotero.Sync.Storage.getSyncState(item.id); - Zotero.Sync.Storage.setSyncedModificationTime(item.id, smtime, true); - Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_IN_SYNC); - Zotero.DB.commitTransaction(); - _changesMade = true; - request.finish(); - return; - } } - if (smtime != mtime) { - var localData = { modTime: smtime }; - var remoteData = { modTime: mtime }; - Zotero.Sync.Storage.QueueManager.addConflict( - request.name, localData, remoteData - ); - Zotero.debug("Conflict -- last synced file mod time " - + "does not match time on storage server" - + " (" + smtime + " != " + mtime + ")"); + if (smtime == mtime) { + Zotero.debug("Stored file mod time matches remote file -- skipping upload"); + + Zotero.DB.beginTransaction(); + var syncState = Zotero.Sync.Storage.getSyncState(item.id); + Zotero.Sync.Storage.setSyncedModificationTime(item.id, smtime, true); + Zotero.Sync.Storage.setSyncState(item.id, Zotero.Sync.Storage.SYNC_STATE_IN_SYNC); + Zotero.DB.commitTransaction(); + _changesMade = true; request.finish(); return; } + + var localData = { modTime: smtime }; + var remoteData = { modTime: mtime }; + Zotero.Sync.Storage.QueueManager.addConflict( + request.name, localData, remoteData + ); + Zotero.debug("Conflict -- last synced file mod time " + + "does not match time on storage server" + + " (" + smtime + " != " + mtime + ")"); + request.finish(); + return; } else { Zotero.debug("Remote file not found for item " + item.id); diff --git a/chrome/skin/default/zotero/preferences.css b/chrome/skin/default/zotero/preferences.css @@ -119,12 +119,11 @@ grid row hbox:first-child #zotero-reset row { margin: 0; - padding: 15px; + padding: 8px; } #zotero-reset row:not(:last-child) { - border-bottom: 1px #999 solid; } #zotero-reset row vbox @@ -155,7 +154,6 @@ grid row hbox:first-child #zotero-reset > hbox { margin-top: 5px; - -moz-box-pack: center; }