From 884e5474fec96324026e5e8409cb4ce664587004 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 13 Sep 2009 07:23:29 +0000 Subject: [PATCH] Zotero File Storage megacommit - Group file sync via Zotero File Storage - Split file syncing into separate modules for ZFS and WebDAV - Dragging items between libraries copies child notes, snapshots/files, and links based on checkboxes for each (enabled by default) in the Zotero preferences - Sync errors now trigger an exclamation/error icon separate from the sync icon, with a popup window displaying the error and an option to report it - Various errors that could cause perpetual sync icon spinning now stop the sync properly - Zotero.Utilities.md5(str) is now md5(strOrFile, base64) - doPost(), doHead(), and retrieveSource() now takes a headers parameter instead of requestContentType - doHead() can now accept an nsIURI (with login credentials), is a background request, and isn't cached - When library access or file writing access is denied during sync, display a warning and then reset local group to server version - Perform additional steps (e.g., removing local groups) when switching sync users to prevent errors - Compare hash as well as mod time when checking for modified local files - Don't trigger notifications when removing groups from the client - Clear relation links to items in removed groups - Zotero.Item.attachmentHash property to get file MD5 - importFromFile() now takes libraryID as a third parameter - Zotero.Attachments.getNumFiles() returns the number of files in the attachment directory - Zotero.Attachments.copyAttachmentToLibrary() copies an attachment item, including files, to another library - Removed Zotero.File.getFileHash() in favor of updated Zotero.Utilities.md5() - Zotero.File.copyDirectory(dir, newDir) copies all files from dir into newDir - Preferences shuffling: OpenURL to Advanced, import/export character set options to Export, "Include URLs of paper articles in references" to Styles - Other stuff I don't remember Suffice it to say, this could use testing. --- chrome/content/zotero/overlay.js | 55 +- chrome/content/zotero/overlay.xul | 5 +- .../content/zotero/preferences/preferences.js | 108 +- .../zotero/preferences/preferences.xul | 218 +- chrome/content/zotero/xpcom/attachments.js | 92 +- .../zotero/xpcom/collectionTreeView.js | 156 +- .../content/zotero/xpcom/data/dataObjects.js | 2 +- chrome/content/zotero/xpcom/data/group.js | 11 + chrome/content/zotero/xpcom/data/item.js | 48 +- chrome/content/zotero/xpcom/data/items.js | 1 - chrome/content/zotero/xpcom/data/relations.js | 39 + chrome/content/zotero/xpcom/db.js | 4 +- chrome/content/zotero/xpcom/error.js | 8 +- chrome/content/zotero/xpcom/file.js | 32 +- chrome/content/zotero/xpcom/itemTreeView.js | 35 +- chrome/content/zotero/xpcom/schema.js | 15 + chrome/content/zotero/xpcom/storage.js | 2139 +++++------------ .../content/zotero/xpcom/storage/session.js | 166 ++ chrome/content/zotero/xpcom/storage/webdav.js | 1401 +++++++++++ chrome/content/zotero/xpcom/storage/zfs.js | 852 +++++++ chrome/content/zotero/xpcom/sync.js | 624 +++-- chrome/content/zotero/xpcom/uri.js | 48 +- chrome/content/zotero/xpcom/utilities.js | 149 +- chrome/content/zotero/xpcom/zotero.js | 19 +- chrome/locale/en-US/zotero/zotero.properties | 1 + chrome/skin/default/zotero/error.png | Bin 0 -> 666 bytes chrome/skin/default/zotero/exclamation.png | Bin 0 -> 701 bytes chrome/skin/default/zotero/overlay.css | 14 +- components/zotero-service.js | 3 + defaults/preferences/zotero.js | 10 +- userdata.sql | 3 +- 31 files changed, 4261 insertions(+), 1997 deletions(-) create mode 100644 chrome/content/zotero/xpcom/storage/session.js create mode 100644 chrome/content/zotero/xpcom/storage/webdav.js create mode 100644 chrome/content/zotero/xpcom/storage/zfs.js create mode 100755 chrome/skin/default/zotero/error.png create mode 100755 chrome/skin/default/zotero/exclamation.png diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index b71e28d64e..d5eeb1c79a 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -177,11 +177,25 @@ var ZoteroPane = new function() ); if (index == 0) { - Zotero.Sync.Server.sync(function () { - pr.alert( - "Restore Completed", - "The local Zotero database has been successfully restored." - ); + Zotero.Sync.Server.sync({ + onSuccess: function () { + Zotero.Sync.Runner.setSyncIcon(); + + pr.alert( + "Restore Completed", + "The local Zotero database has been successfully restored." + ); + }, + + onError: function (msg) { + pr.alert( + "Restore Failed", + "An error occurred while restoring from the server:\n\n" + + msg + ); + + Zotero.Sync.Runner.error(msg); + } }); } }, 1000); @@ -898,7 +912,7 @@ var ZoteroPane = new function() if (!tagSelector.getAttribute('collapsed') || tagSelector.getAttribute('collapsed') == 'false') { Zotero.debug('Updating tag selector with current tags'); - if (itemGroup.isEditable()) { + if (itemGroup.editable) { tagSelector.mode = 'edit'; } else { @@ -2281,7 +2295,7 @@ var ZoteroPane = new function() var disabled = Zotero.locked; if (!disabled && self.collectionsView.selection && self.collectionsView.selection.count) { var itemGroup = self.collectionsView._getItemAtRow(self.collectionsView.selection.currentIndex); - disabled = !itemGroup.isEditable() + disabled = !itemGroup.editable; } for each(var menuitem in menu.firstChild.childNodes) { menuitem.disabled = disabled; @@ -2837,7 +2851,26 @@ var ZoteroPane = new function() } var itemGroup = this.collectionsView._getItemAtRow(row); - return itemGroup.isEditable(); + return itemGroup.editable; + } + + + /** + * Test if the user can edit the currently selected library/collection, + * and display an error if not + * + * @param {Integer} [row] + * + * @return {Boolean} TRUE if user can edit, FALSE if not + */ + this.canEditFiles = function (row) { + // Currently selected row + if (row === undefined) { + row = this.collectionsView.selection.currentIndex; + } + + var itemGroup = this.collectionsView._getItemAtRow(row); + return itemGroup.filesEditable; } @@ -2999,12 +3032,6 @@ 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; // TODO: localize msg = 'Last sync: '; diff --git a/chrome/content/zotero/overlay.xul b/chrome/content/zotero/overlay.xul index e2bdb9014b..f923f9251e 100644 --- a/chrome/content/zotero/overlay.xul +++ b/chrome/content/zotero/overlay.xul @@ -164,8 +164,8 @@