commit c6cb46907e566cd6c28b0c509e52c8a47f1b0dea
parent 2f9306598660923ed4bbaf8ed06896dbb928bea5
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 16 Jun 2017 04:49:08 -0400
Disable full-text content processor during sync and on pref off
Turning off full-text content syncing now stops the background processor
Diffstat:
1 file changed, 34 insertions(+), 3 deletions(-)
diff --git a/chrome/content/zotero/xpcom/fulltext.js b/chrome/content/zotero/xpcom/fulltext.js
@@ -99,8 +99,36 @@ Zotero.Fulltext = Zotero.FullText = new function(){
yield this.registerPDFTool('converter');
yield this.registerPDFTool('info');
- Zotero.uiReadyPromise.delay(30000).then(() => this.startContentProcessor());
- Zotero.addShutdownListener(this.stopContentProcessor.bind(this));
+ Zotero.uiReadyPromise.delay(30000).then(() => {
+ this.startContentProcessor();
+ Zotero.addShutdownListener(this.stopContentProcessor.bind(this));
+
+ // Start/stop content processor with full-text content syncing pref
+ Zotero.Prefs.registerObserver('sync.fulltext.enabled', (enabled) => {
+ if (enabled) {
+ this.startContentProcessor();
+ }
+ else {
+ this.stopContentProcessor();
+ }
+ });
+
+ // Stop content processor during syncs
+ Zotero.Notifier.registerObserver(
+ {
+ notify: Zotero.Promise.method(function (event, type, ids, extraData) {
+ if (event == 'start') {
+ this.stopContentProcessor();
+ }
+ else if (event == 'stop') {
+ this.startContentProcessor();
+ }
+ }.bind(this))
+ },
+ ['sync'],
+ 'fulltext'
+ );
+ });
});
@@ -1014,8 +1042,10 @@ Zotero.Fulltext = Zotero.FullText = new function(){
* Start the idle observer for the background content processor
*/
this.startContentProcessor = function () {
+ if (!Zotero.Prefs.get('sync.fulltext.enabled')) return;
+
if (!_idleObserverIsRegistered) {
- Zotero.debug("Initializing full-text content ingester idle observer");
+ Zotero.debug("Starting full-text content processor");
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
.getService(Components.interfaces.nsIIdleService);
idleService.addIdleObserver(this.idleObserver, _idleObserverDelay);
@@ -1028,6 +1058,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
*/
this.stopContentProcessor = function () {
if (_idleObserverIsRegistered) {
+ Zotero.debug("Stopping full-text content processor");
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
.getService(Components.interfaces.nsIIdleService);
idleService.removeIdleObserver(this.idleObserver, _idleObserverDelay);