www

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

commit a3a7a1d0cf1106c4eefaccf736d7ae1d1a3d8fda
parent 0c3529170f304e6ff9d5792d27666ee9046c5e07
Author: Dan Stillman <dstillman@zotero.org>
Date:   Tue,  5 Nov 2013 05:01:35 -0500

Add pref to disable full-text syncing, and prompt existing users on sync

FT sync is enabled by default for new users and configurable in the Sync
prefs.

Also disable downgrades once full-text sync is enabled, since otherwise
someone switching back and forth between old and new versions could miss
full-text content updates.

Diffstat:
Mchrome/content/zotero/preferences/preferences_sync.xul | 10++++++++++
Mchrome/content/zotero/xpcom/schema.js | 11+++++++++--
Mchrome/content/zotero/xpcom/sync.js | 103+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------
Mchrome/content/zotero/xpcom/zotero.js | 15+++++++++++++--
Mdefaults/preferences/zotero.js | 1+
5 files changed, 107 insertions(+), 33 deletions(-)

diff --git a/chrome/content/zotero/preferences/preferences_sync.xul b/chrome/content/zotero/preferences/preferences_sync.xul @@ -32,6 +32,7 @@ <preferences> <preference id="pref-sync-autosync" name="extensions.zotero.sync.autoSync" type="bool"/> <preference id="pref-sync-username" name="extensions.zotero.sync.server.username" type="string" instantApply="true"/> + <preference id="pref-sync-fulltext-enabled" name="extensions.zotero.sync.fulltext.enabled" type="bool"/> <preference id="pref-storage-enabled" name="extensions.zotero.sync.storage.enabled" type="bool"/> <preference id="pref-storage-protocol" name="extensions.zotero.sync.storage.protocol" type="string" onchange="Zotero_Preferences.Sync.unverifyStorageServer()"/> @@ -76,6 +77,15 @@ <box/> <checkbox label="&zotero.preferences.sync.syncAutomatically;" preference="pref-sync-autosync"/> </row> + <row> + <box/> + <vbox> + <!-- TODO: localize --> + <checkbox label="Sync full-text content" + preference="pref-sync-fulltext-enabled" + tooltiptext="Zotero can sync the full-text content of files in your Zotero libraries with zotero.org and other computers, allowing you to easily search for your files wherever you are. The full-text content of your files will not be shared publicly."/> + </vbox> + </row> <!-- <row> <box/> diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js @@ -1446,7 +1446,10 @@ Zotero.Schema = new function(){ Zotero.Schema.updateCustomTables(true); _updateDBVersion('system', _getSchemaSQLVersion('system')); - _updateDBVersion('userdata', _getSchemaSQLVersion('userdata')); + // TEMP: 77 is for full-text syncing. New users don't need the + // prompt, so initialize new databases to 77. + //_updateDBVersion('userdata', _getSchemaSQLVersion('userdata')); + _updateDBVersion('userdata', 77); _updateDBVersion('userdata2', _getSchemaSQLVersion('userdata2')); _updateDBVersion('triggers', _getSchemaSQLVersion('triggers')); @@ -1792,7 +1795,11 @@ Zotero.Schema = new function(){ return false; } - if (fromVersion > toVersion){ + // 77 is a hack for full-text content syncing + if (fromVersion == 77) { + return false; + } + else if (fromVersion > toVersion) { throw("Zotero user data DB version is newer than SQL file"); } diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js @@ -1368,6 +1368,44 @@ Zotero.Sync.Server = new function () { _error(e); } + // TEMP + if (Zotero.Prefs.get("sync.fulltext.enabled") && + Zotero.DB.valueQuery("SELECT version FROM version WHERE schema='userdata'") < 77) { + // Don't show multiple times on idle + _syncInProgress = true; + + let ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + let buttonFlags = (ps.BUTTON_POS_0) * (ps.BUTTON_TITLE_IS_STRING) + + (ps.BUTTON_POS_1) * (ps.BUTTON_TITLE_IS_STRING) + + ps.BUTTON_DELAY_ENABLE; + let index = ps.confirmEx( + null, + "New: Full-Text Content Syncing", + "Zotero can now sync the full-text content of files in your Zotero libraries " + + "with zotero.org and other computers, allowing you to easily search for " + + "your files wherever you are. The full-text content of your files will " + + "not be shared publicly.\n\n" + + "You can change this setting later from the Sync pane of the Zotero " + + "preferences.", + buttonFlags, + "Use Full-Text Syncing", + "Not Now", + null, null, {} + ); + + _syncInProgress = false; + + // Enable + if (index == 0) { + Zotero.DB.query("UPDATE version SET version=77 WHERE schema='userdata'"); + } + // Disable + else { + Zotero.Prefs.set("sync.fulltext.enabled", false); + } + } + username = encodeURIComponent(username); password = encodeURIComponent(password); var body = _apiVersionComponent @@ -1469,7 +1507,12 @@ Zotero.Sync.Server = new function () { body += '&upload=1'; } - body += Zotero.Fulltext.getUndownloadedPostData(); + if (Zotero.Prefs.get("sync.fulltext.enabled")) { + body += "&ft=1" + Zotero.Fulltext.getUndownloadedPostData(); + } + else { + body += "&ft=0"; + } Zotero.Sync.Runner.setSyncStatus(Zotero.getString('sync.status.gettingUpdatedData')); @@ -3574,34 +3617,36 @@ Zotero.Sync.Server.Data = new function() { docElem.appendChild(settingsNode); } - // Add up to 500K characters of full-text content - try { - var rows = Zotero.Fulltext.getUnsyncedContent(500000); - } - catch (e) { - Zotero.debug(e, 1); - Components.utils.reportError(e); - var rows = []; - } - if (rows.length) { - let fulltextsNode = doc.createElement('fulltexts'); - syncSession.fulltextItems = []; - for (let i=0; i<rows.length; i++) { - syncSession.fulltextItems.push({ - libraryID: rows[i].libraryID, - key: rows[i].key - }) - let node = doc.createElement('fulltext'); - node.setAttribute('libraryID', rows[i].libraryID ? rows[i].libraryID : Zotero.libraryID); - node.setAttribute('key', rows[i].key); - node.setAttribute('indexedChars', rows[i].indexedChars); - node.setAttribute('totalChars', rows[i].totalChars); - node.setAttribute('indexedPages', rows[i].indexedPages); - node.setAttribute('totalPages', rows[i].totalPages); - node.appendChild(doc.createTextNode(_xmlize(rows[i].text))); - fulltextsNode.appendChild(node); - } - docElem.appendChild(fulltextsNode); + if (Zotero.Prefs.get("sync.fulltext.enabled")) { + // Add up to 500K characters of full-text content + try { + var rows = Zotero.Fulltext.getUnsyncedContent(500000); + } + catch (e) { + Zotero.debug(e, 1); + Components.utils.reportError(e); + var rows = []; + } + if (rows.length) { + let fulltextsNode = doc.createElement('fulltexts'); + syncSession.fulltextItems = []; + for (let i=0; i<rows.length; i++) { + syncSession.fulltextItems.push({ + libraryID: rows[i].libraryID, + key: rows[i].key + }) + let node = doc.createElement('fulltext'); + node.setAttribute('libraryID', rows[i].libraryID ? rows[i].libraryID : Zotero.libraryID); + node.setAttribute('key', rows[i].key); + node.setAttribute('indexedChars', rows[i].indexedChars); + node.setAttribute('totalChars', rows[i].totalChars); + node.setAttribute('indexedPages', rows[i].indexedPages); + node.setAttribute('totalPages', rows[i].totalPages); + node.appendChild(doc.createTextNode(_xmlize(rows[i].text))); + fulltextsNode.appendChild(node); + } + docElem.appendChild(fulltextsNode); + } } // Deletions diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -548,8 +548,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); Zotero.DB.addCallback('commit', Zotero.Notifier.commit); Zotero.DB.addCallback('rollback', Zotero.Notifier.reset); - Zotero.Fulltext.init(); - // Require >=2.1b3 database to ensure proper locking if (Zotero.isStandalone && Zotero.Schema.getDBVersion('system') > 0 && Zotero.Schema.getDBVersion('system') < 31) { var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] @@ -641,6 +639,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } } + Zotero.Fulltext.init(); + Zotero.DB.startDummyStatement(); // Populate combined tables for custom types and fields -- this is likely temporary @@ -2275,6 +2275,17 @@ Zotero.Prefs = new function(){ } break; + // TEMP + case "sync.fulltext.enabled": + if (this.get("sync.fulltext.enabled")) { + // Disable downgrades if full-text sync is enabled, since otherwise + // we could miss full-text content updates + if (Zotero.DB.valueQuery("SELECT version FROM version WHERE schema='userdata'") < 77) { + Zotero.DB.query("UPDATE version SET version=77 WHERE schema='userdata'"); + } + } + break; + case "search.quicksearch-mode": var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] .getService(Components.interfaces.nsIWindowMediator); diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js @@ -144,6 +144,7 @@ pref("extensions.zotero.sync.storage.deleteDelayDays", 30); pref("extensions.zotero.sync.storage.groups.enabled", true); pref("extensions.zotero.sync.storage.downloadMode.personal", "on-sync"); pref("extensions.zotero.sync.storage.downloadMode.groups", "on-sync"); +pref("extensions.zotero.sync.fulltext.enabled", true); // Proxy pref("extensions.zotero.proxies.autoRecognize", true);