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.
This commit is contained in:
parent
0c3529170f
commit
a3a7a1d0cf
5 changed files with 106 additions and 32 deletions
|
@ -32,6 +32,7 @@
|
||||||
<preferences>
|
<preferences>
|
||||||
<preference id="pref-sync-autosync" name="extensions.zotero.sync.autoSync" type="bool"/>
|
<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-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-enabled" name="extensions.zotero.sync.storage.enabled" type="bool"/>
|
||||||
<preference id="pref-storage-protocol" name="extensions.zotero.sync.storage.protocol" type="string"
|
<preference id="pref-storage-protocol" name="extensions.zotero.sync.storage.protocol" type="string"
|
||||||
onchange="Zotero_Preferences.Sync.unverifyStorageServer()"/>
|
onchange="Zotero_Preferences.Sync.unverifyStorageServer()"/>
|
||||||
|
@ -76,6 +77,15 @@
|
||||||
<box/>
|
<box/>
|
||||||
<checkbox label="&zotero.preferences.sync.syncAutomatically;" preference="pref-sync-autosync"/>
|
<checkbox label="&zotero.preferences.sync.syncAutomatically;" preference="pref-sync-autosync"/>
|
||||||
</row>
|
</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>
|
<row>
|
||||||
<box/>
|
<box/>
|
||||||
|
|
|
@ -1446,7 +1446,10 @@ Zotero.Schema = new function(){
|
||||||
Zotero.Schema.updateCustomTables(true);
|
Zotero.Schema.updateCustomTables(true);
|
||||||
|
|
||||||
_updateDBVersion('system', _getSchemaSQLVersion('system'));
|
_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('userdata2', _getSchemaSQLVersion('userdata2'));
|
||||||
_updateDBVersion('triggers', _getSchemaSQLVersion('triggers'));
|
_updateDBVersion('triggers', _getSchemaSQLVersion('triggers'));
|
||||||
|
|
||||||
|
@ -1792,7 +1795,11 @@ Zotero.Schema = new function(){
|
||||||
return false;
|
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");
|
throw("Zotero user data DB version is newer than SQL file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1368,6 +1368,44 @@ Zotero.Sync.Server = new function () {
|
||||||
_error(e);
|
_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);
|
username = encodeURIComponent(username);
|
||||||
password = encodeURIComponent(password);
|
password = encodeURIComponent(password);
|
||||||
var body = _apiVersionComponent
|
var body = _apiVersionComponent
|
||||||
|
@ -1469,7 +1507,12 @@ Zotero.Sync.Server = new function () {
|
||||||
body += '&upload=1';
|
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'));
|
Zotero.Sync.Runner.setSyncStatus(Zotero.getString('sync.status.gettingUpdatedData'));
|
||||||
|
|
||||||
|
@ -3574,34 +3617,36 @@ Zotero.Sync.Server.Data = new function() {
|
||||||
docElem.appendChild(settingsNode);
|
docElem.appendChild(settingsNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add up to 500K characters of full-text content
|
if (Zotero.Prefs.get("sync.fulltext.enabled")) {
|
||||||
try {
|
// Add up to 500K characters of full-text content
|
||||||
var rows = Zotero.Fulltext.getUnsyncedContent(500000);
|
try {
|
||||||
}
|
var rows = Zotero.Fulltext.getUnsyncedContent(500000);
|
||||||
catch (e) {
|
}
|
||||||
Zotero.debug(e, 1);
|
catch (e) {
|
||||||
Components.utils.reportError(e);
|
Zotero.debug(e, 1);
|
||||||
var rows = [];
|
Components.utils.reportError(e);
|
||||||
}
|
var rows = [];
|
||||||
if (rows.length) {
|
}
|
||||||
let fulltextsNode = doc.createElement('fulltexts');
|
if (rows.length) {
|
||||||
syncSession.fulltextItems = [];
|
let fulltextsNode = doc.createElement('fulltexts');
|
||||||
for (let i=0; i<rows.length; i++) {
|
syncSession.fulltextItems = [];
|
||||||
syncSession.fulltextItems.push({
|
for (let i=0; i<rows.length; i++) {
|
||||||
libraryID: rows[i].libraryID,
|
syncSession.fulltextItems.push({
|
||||||
key: rows[i].key
|
libraryID: rows[i].libraryID,
|
||||||
})
|
key: rows[i].key
|
||||||
let node = doc.createElement('fulltext');
|
})
|
||||||
node.setAttribute('libraryID', rows[i].libraryID ? rows[i].libraryID : Zotero.libraryID);
|
let node = doc.createElement('fulltext');
|
||||||
node.setAttribute('key', rows[i].key);
|
node.setAttribute('libraryID', rows[i].libraryID ? rows[i].libraryID : Zotero.libraryID);
|
||||||
node.setAttribute('indexedChars', rows[i].indexedChars);
|
node.setAttribute('key', rows[i].key);
|
||||||
node.setAttribute('totalChars', rows[i].totalChars);
|
node.setAttribute('indexedChars', rows[i].indexedChars);
|
||||||
node.setAttribute('indexedPages', rows[i].indexedPages);
|
node.setAttribute('totalChars', rows[i].totalChars);
|
||||||
node.setAttribute('totalPages', rows[i].totalPages);
|
node.setAttribute('indexedPages', rows[i].indexedPages);
|
||||||
node.appendChild(doc.createTextNode(_xmlize(rows[i].text)));
|
node.setAttribute('totalPages', rows[i].totalPages);
|
||||||
fulltextsNode.appendChild(node);
|
node.appendChild(doc.createTextNode(_xmlize(rows[i].text)));
|
||||||
|
fulltextsNode.appendChild(node);
|
||||||
|
}
|
||||||
|
docElem.appendChild(fulltextsNode);
|
||||||
}
|
}
|
||||||
docElem.appendChild(fulltextsNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deletions
|
// Deletions
|
||||||
|
|
|
@ -548,8 +548,6 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
||||||
Zotero.DB.addCallback('commit', Zotero.Notifier.commit);
|
Zotero.DB.addCallback('commit', Zotero.Notifier.commit);
|
||||||
Zotero.DB.addCallback('rollback', Zotero.Notifier.reset);
|
Zotero.DB.addCallback('rollback', Zotero.Notifier.reset);
|
||||||
|
|
||||||
Zotero.Fulltext.init();
|
|
||||||
|
|
||||||
// Require >=2.1b3 database to ensure proper locking
|
// Require >=2.1b3 database to ensure proper locking
|
||||||
if (Zotero.isStandalone && Zotero.Schema.getDBVersion('system') > 0 && Zotero.Schema.getDBVersion('system') < 31) {
|
if (Zotero.isStandalone && Zotero.Schema.getDBVersion('system') > 0 && Zotero.Schema.getDBVersion('system') < 31) {
|
||||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
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();
|
Zotero.DB.startDummyStatement();
|
||||||
|
|
||||||
// Populate combined tables for custom types and fields -- this is likely temporary
|
// Populate combined tables for custom types and fields -- this is likely temporary
|
||||||
|
@ -2275,6 +2275,17 @@ Zotero.Prefs = new function(){
|
||||||
}
|
}
|
||||||
break;
|
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":
|
case "search.quicksearch-mode":
|
||||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||||
.getService(Components.interfaces.nsIWindowMediator);
|
.getService(Components.interfaces.nsIWindowMediator);
|
||||||
|
|
|
@ -144,6 +144,7 @@ pref("extensions.zotero.sync.storage.deleteDelayDays", 30);
|
||||||
pref("extensions.zotero.sync.storage.groups.enabled", true);
|
pref("extensions.zotero.sync.storage.groups.enabled", true);
|
||||||
pref("extensions.zotero.sync.storage.downloadMode.personal", "on-sync");
|
pref("extensions.zotero.sync.storage.downloadMode.personal", "on-sync");
|
||||||
pref("extensions.zotero.sync.storage.downloadMode.groups", "on-sync");
|
pref("extensions.zotero.sync.storage.downloadMode.groups", "on-sync");
|
||||||
|
pref("extensions.zotero.sync.fulltext.enabled", true);
|
||||||
|
|
||||||
// Proxy
|
// Proxy
|
||||||
pref("extensions.zotero.proxies.autoRecognize", true);
|
pref("extensions.zotero.proxies.autoRecognize", true);
|
||||||
|
|
Loading…
Reference in a new issue