Disable full-text content processor during sync and on pref off

Turning off full-text content syncing now stops the background processor
This commit is contained in:
Dan Stillman 2017-06-16 04:49:08 -04:00
parent 2f93065986
commit c6cb46907e

View File

@ -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);