Much improved storage syncing (theoretically)
Metadata sync now always runs before storage sync, and file transfers can be stopped. Needs testing
This commit is contained in:
parent
70e5e6f7bd
commit
49a7537fa6
9 changed files with 1130 additions and 725 deletions
|
@ -2208,6 +2208,25 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setLastSyncStatus = function (tooltip) {
|
||||||
|
var label = tooltip.firstChild.nextSibling;
|
||||||
|
|
||||||
|
var msg = Zotero.Sync.Runner.lastSyncError;
|
||||||
|
if (msg) {
|
||||||
|
label.value = 'Last error: ' + msg; // TODO: localize
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastSyncTime = Zotero.Sync.Server.lastLocalSyncTime;
|
||||||
|
msg = 'Last sync: ' // TODO: localize
|
||||||
|
+ (lastSyncTime
|
||||||
|
? new Date(lastSyncTime * 1000).toLocaleString()
|
||||||
|
: 'Not yet synced'
|
||||||
|
);
|
||||||
|
label.value = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function reportErrors() {
|
function reportErrors() {
|
||||||
var errors = Zotero.getErrors(true);
|
var errors = Zotero.getErrors(true);
|
||||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||||
|
|
|
@ -311,11 +311,14 @@
|
||||||
|
|
||||||
<vbox id="zotero-item-pane" persist="width">
|
<vbox id="zotero-item-pane" persist="width">
|
||||||
<toolbar align="center" pack="end">
|
<toolbar align="center" pack="end">
|
||||||
<progressmeter id="zotero-tb-syncProgress" mode="determined"
|
<hbox id="zotero-tb-sync-progress-box" hidden="true" align="center">
|
||||||
value="0" tooltip="zotero-tb-syncProgress-tooltip"
|
<toolbarbutton id="zotero-tb-sync-storage-cancel"
|
||||||
hidden="true">
|
tooltiptext="Cancel Storage Sync"
|
||||||
|
oncommand="Zotero.Sync.Storage.QueueManager.cancel()"/>
|
||||||
|
<progressmeter id="zotero-tb-sync-progress" mode="determined"
|
||||||
|
value="0" tooltip="zotero-tb-sync-progress-tooltip">
|
||||||
</progressmeter>
|
</progressmeter>
|
||||||
<tooltip id="zotero-tb-syncProgress-tooltip" noautohide="true">
|
<tooltip id="zotero-tb-sync-progress-tooltip" noautohide="true">
|
||||||
<grid>
|
<grid>
|
||||||
<columns>
|
<columns>
|
||||||
<column/>
|
<column/>
|
||||||
|
@ -324,35 +327,32 @@
|
||||||
<rows>
|
<rows>
|
||||||
<row>
|
<row>
|
||||||
<label value="&zotero.sync.storage.progress;"/>
|
<label value="&zotero.sync.storage.progress;"/>
|
||||||
<label id="zotero-tb-syncProgress-tooltip-progress"/>
|
<label id="zotero-tb-sync-progress-tooltip-progress"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<label value="&zotero.sync.storage.downloads;"/>
|
<label value="&zotero.sync.storage.downloads;"/>
|
||||||
<label
|
<label
|
||||||
id="zotero-tb-syncProgress-tooltip-downloads"/>
|
id="zotero-tb-sync-progress-tooltip-downloads"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<label value="&zotero.sync.storage.uploads;"/>
|
<label value="&zotero.sync.storage.uploads;"/>
|
||||||
<label
|
<label
|
||||||
id="zotero-tb-syncProgress-tooltip-uploads"/>
|
id="zotero-tb-sync-progress-tooltip-uploads"/>
|
||||||
</row>
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
</tooltip>
|
</tooltip>
|
||||||
|
</hbox>
|
||||||
<toolbarbutton id="zotero-tb-sync" tooltip="_child"
|
<toolbarbutton id="zotero-tb-sync" tooltip="_child"
|
||||||
oncommand="Zotero.Sync.Runner.sync()">
|
oncommand="Zotero.Sync.Runner.sync()">
|
||||||
<tooltip
|
<tooltip
|
||||||
onpopupshowing="if (Zotero.Sync.Runner.lastSyncError) { this.firstChild.nextSibling.value = 'Last error: ' + Zotero.Sync.Runner.lastSyncError; return; } this.firstChild.nextSibling.value = 'Last sync: ' + (Zotero.Sync.Server.lastLocalSyncTime ? new Date(Zotero.Sync.Server.lastLocalSyncTime * 1000).toLocaleString() : 'Not yet synced')"
|
onpopupshowing="ZoteroPane.setLastSyncStatus(this)"
|
||||||
noautohide="true"><!-- TODO: localize -->
|
noautohide="true">
|
||||||
|
<!-- TODO: localize -->
|
||||||
<label value="Sync with Zotero Server"/>
|
<label value="Sync with Zotero Server"/>
|
||||||
<label id="zotero-last-sync-time"/>
|
<label id="zotero-last-sync-time"/>
|
||||||
</tooltip>
|
</tooltip>
|
||||||
</toolbarbutton>
|
</toolbarbutton>
|
||||||
<!--
|
|
||||||
<toolbarbutton id="zotero-tb-storage-sync"
|
|
||||||
tooltiptext="Sync with Storage Server"
|
|
||||||
oncommand="Zotero.Sync.Storage.sync()"/>
|
|
||||||
-->
|
|
||||||
<toolbarseparator/>
|
<toolbarseparator/>
|
||||||
<toolbarbutton id="zotero-tb-fullscreen" tooltiptext="&zotero.toolbar.fullscreen.tooltip;" oncommand="ZoteroPane.fullScreen();"/>
|
<toolbarbutton id="zotero-tb-fullscreen" tooltiptext="&zotero.toolbar.fullscreen.tooltip;" oncommand="ZoteroPane.fullScreen();"/>
|
||||||
<toolbarbutton class="tabs-closebutton" oncommand="ZoteroPane.toggleDisplay()"/>
|
<toolbarbutton class="tabs-closebutton" oncommand="ZoteroPane.toggleDisplay()"/>
|
||||||
|
|
|
@ -38,7 +38,6 @@ Zotero.Attachments = new function(){
|
||||||
this.createDirectoryForItem = createDirectoryForItem;
|
this.createDirectoryForItem = createDirectoryForItem;
|
||||||
this.createDirectoryForMissingItem = createDirectoryForMissingItem;
|
this.createDirectoryForMissingItem = createDirectoryForMissingItem;
|
||||||
this.getStorageDirectory = getStorageDirectory;
|
this.getStorageDirectory = getStorageDirectory;
|
||||||
this.getMissingStorageDirectory = getMissingStorageDirectory;
|
|
||||||
this.getPath = getPath;
|
this.getPath = getPath;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -907,7 +906,7 @@ Zotero.Attachments = new function(){
|
||||||
* @param string key Item secondary lookup key
|
* @param string key Item secondary lookup key
|
||||||
*/
|
*/
|
||||||
function createDirectoryForMissingItem(key) {
|
function createDirectoryForMissingItem(key) {
|
||||||
var dir = this.getMissingStorageDirectory(key);
|
var dir = this.getStorageDirectoryByKey(key);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
dir.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755);
|
||||||
}
|
}
|
||||||
|
@ -923,10 +922,10 @@ Zotero.Attachments = new function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getMissingStorageDirectory(key) {
|
this.getStorageDirectoryByKey = function (key) {
|
||||||
if (typeof key != 'string' || !key.match(/^[A-Z0-9]{8}$/)) {
|
if (typeof key != 'string' || !key.match(/^[A-Z0-9]{8}$/)) {
|
||||||
throw ('key must be an 8-character string in '
|
throw ('key must be an 8-character string in '
|
||||||
+ 'Zotero.Attachments.getMissingStorageDirectory()')
|
+ 'Zotero.Attachments.getStorageDirectoryByKey()')
|
||||||
}
|
}
|
||||||
var dir = Zotero.getStorageDirectory();
|
var dir = Zotero.getStorageDirectory();
|
||||||
dir.append(key);
|
dir.append(key);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -391,9 +391,6 @@ Zotero.Sync.Runner = new function () {
|
||||||
this.__defineGetter__("lastSyncError", function () {
|
this.__defineGetter__("lastSyncError", function () {
|
||||||
return _lastSyncError;
|
return _lastSyncError;
|
||||||
});
|
});
|
||||||
this.__defineSetter__("lastSyncError", function (val) {
|
|
||||||
_lastSyncError = val ? val : '';
|
|
||||||
});
|
|
||||||
|
|
||||||
var _lastSyncError;
|
var _lastSyncError;
|
||||||
var _autoSyncTimer;
|
var _autoSyncTimer;
|
||||||
|
@ -406,7 +403,7 @@ Zotero.Sync.Runner = new function () {
|
||||||
|
|
||||||
this.sync = function () {
|
this.sync = function () {
|
||||||
if (Zotero.Utilities.HTTP.browserIsOffline()){
|
if (Zotero.Utilities.HTTP.browserIsOffline()){
|
||||||
this.lastSyncError = "Browser is offline"; // TODO: localize
|
_lastSyncError = "Browser is offline"; // TODO: localize
|
||||||
this.clearSyncTimeout(); // DEBUG: necessary?
|
this.clearSyncTimeout(); // DEBUG: necessary?
|
||||||
this.setSyncIcon('error');
|
this.setSyncIcon('error');
|
||||||
return false;
|
return false;
|
||||||
|
@ -416,12 +413,13 @@ Zotero.Sync.Runner = new function () {
|
||||||
throw ("Sync already running in Zotero.Sync.Runner.sync()");
|
throw ("Sync already running in Zotero.Sync.Runner.sync()");
|
||||||
}
|
}
|
||||||
_queue = [
|
_queue = [
|
||||||
|
Zotero.Sync.Server.sync,
|
||||||
Zotero.Sync.Storage.sync,
|
Zotero.Sync.Storage.sync,
|
||||||
Zotero.Sync.Server.sync,
|
Zotero.Sync.Server.sync,
|
||||||
Zotero.Sync.Storage.sync
|
Zotero.Sync.Storage.sync
|
||||||
];
|
];
|
||||||
_running = true;
|
_running = true;
|
||||||
this.lastSyncError = '';
|
_lastSyncError = '';
|
||||||
this.clearSyncTimeout();
|
this.clearSyncTimeout();
|
||||||
this.setSyncIcon('animate');
|
this.setSyncIcon('animate');
|
||||||
this.next();
|
this.next();
|
||||||
|
@ -439,6 +437,12 @@ Zotero.Sync.Runner = new function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.setError = function (msg) {
|
||||||
|
this.setSyncIcon('error');
|
||||||
|
_lastSyncError = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.reset = function () {
|
this.reset = function () {
|
||||||
_queue = [];
|
_queue = [];
|
||||||
_running = false;
|
_running = false;
|
||||||
|
@ -1247,13 +1251,7 @@ Zotero.Sync.Server = new function () {
|
||||||
Zotero.Sync.Server.unlock()
|
Zotero.Sync.Server.unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.Sync.Runner.setSyncIcon('error');
|
Zotero.Sync.Runner.setError(e.message ? e.message : e);
|
||||||
if (e.name) {
|
|
||||||
Zotero.Sync.Runner.lastSyncError = e.name;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Zotero.Sync.Runner.lastSyncError = e;
|
|
||||||
}
|
|
||||||
Zotero.Sync.Runner.reset();
|
Zotero.Sync.Runner.reset();
|
||||||
throw(e);
|
throw(e);
|
||||||
}
|
}
|
||||||
|
@ -1998,7 +1996,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
var type = Type.toLowerCase(); // 'item'
|
var type = Type.toLowerCase(); // 'item'
|
||||||
var types = Types.toLowerCase(); // 'items'
|
var types = Types.toLowerCase(); // 'items'
|
||||||
|
|
||||||
if (!ids.updated[types]) {
|
if (!ids.updated[types] || !ids.updated[types].length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2031,7 +2029,7 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
var type = Type.toLowerCase(); // 'item'
|
var type = Type.toLowerCase(); // 'item'
|
||||||
var types = Types.toLowerCase(); // 'items'
|
var types = Types.toLowerCase(); // 'items'
|
||||||
|
|
||||||
if (!ids.deleted[types]) {
|
if (!ids.deleted[types] || !ids.deleted[types].length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -426,6 +426,33 @@ Zotero.Utilities.prototype.lpad = function(string, pad, length) {
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Port of PHP's number_format()
|
||||||
|
*
|
||||||
|
* MIT Licensed
|
||||||
|
*
|
||||||
|
* From http://kevin.vanzonneveld.net
|
||||||
|
* + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
|
||||||
|
* + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||||
|
* + bugfix by: Michael White (http://getsprink.com)
|
||||||
|
* + bugfix by: Benjamin Lupton
|
||||||
|
* + bugfix by: Allan Jensen (http://www.winternet.no)
|
||||||
|
* + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
|
||||||
|
* + bugfix by: Howard Yeend
|
||||||
|
* * example 1: number_format(1234.5678, 2, '.', '');
|
||||||
|
* * returns 1: 1234.57
|
||||||
|
*/
|
||||||
|
Zotero.Utilities.prototype.numberFormat = function (number, decimals, dec_point, thousands_sep) {
|
||||||
|
var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
|
||||||
|
var d = dec_point == undefined ? "." : dec_point;
|
||||||
|
var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
|
||||||
|
var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
|
||||||
|
|
||||||
|
return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests if an item type exists
|
* Tests if an item type exists
|
||||||
*
|
*
|
||||||
|
|
|
@ -274,7 +274,6 @@ var Zotero = new function(){
|
||||||
|
|
||||||
Zotero.Sync.init();
|
Zotero.Sync.init();
|
||||||
Zotero.Sync.Runner.init();
|
Zotero.Sync.Runner.init();
|
||||||
Zotero.Sync.Storage.init();
|
|
||||||
|
|
||||||
Zotero.MIMETypeHandler.init();
|
Zotero.MIMETypeHandler.init();
|
||||||
Zotero.Proxies.init();
|
Zotero.Proxies.init();
|
||||||
|
|
|
@ -506,6 +506,7 @@ styles.deleteStyle = Are you sure you want to delete the style "%1$S"?
|
||||||
styles.deleteStyles = Are you sure you want to delete the selected styles?
|
styles.deleteStyles = Are you sure you want to delete the selected styles?
|
||||||
|
|
||||||
sync.storage.kbRemaining = %SKB remaining
|
sync.storage.kbRemaining = %SKB remaining
|
||||||
|
sync.storage.filesRemaining = %1$S/%2$S files
|
||||||
sync.storage.none = None
|
sync.storage.none = None
|
||||||
|
|
||||||
proxies.multiSite = Multi-Site
|
proxies.multiSite = Multi-Site
|
||||||
|
|
|
@ -191,14 +191,21 @@
|
||||||
list-style-image: url('chrome://zotero/skin/toolbar-advanced-search.png');
|
list-style-image: url('chrome://zotero/skin/toolbar-advanced-search.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
#zotero-tb-syncProgress
|
#zotero-tb-sync-storage-cancel
|
||||||
|
{
|
||||||
|
list-style-image: url(chrome://zotero/skin/control_stop_blue.png);
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#zotero-tb-sync-progress
|
||||||
{
|
{
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 10px;
|
height: 10px;
|
||||||
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#zotero-tb-syncProgress-tooltip row label:first-child
|
#zotero-tb-sync-progress-tooltip row label:first-child
|
||||||
{
|
{
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
Loading…
Add table
Reference in a new issue