- 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
This commit is contained in:
Dan Stillman 2009-07-15 07:27:53 +00:00
parent 9c8738dca0
commit d106fc0313
6 changed files with 87 additions and 38 deletions

View File

@ -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')) {

View File

@ -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"/>

View File

@ -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()");
}

View File

@ -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>

View File

@ -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);

View File

@ -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;
}