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:
parent
2f93065986
commit
c6cb46907e
|
@ -99,8 +99,36 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
yield this.registerPDFTool('converter');
|
yield this.registerPDFTool('converter');
|
||||||
yield this.registerPDFTool('info');
|
yield this.registerPDFTool('info');
|
||||||
|
|
||||||
Zotero.uiReadyPromise.delay(30000).then(() => this.startContentProcessor());
|
Zotero.uiReadyPromise.delay(30000).then(() => {
|
||||||
|
this.startContentProcessor();
|
||||||
Zotero.addShutdownListener(this.stopContentProcessor.bind(this));
|
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
|
* Start the idle observer for the background content processor
|
||||||
*/
|
*/
|
||||||
this.startContentProcessor = function () {
|
this.startContentProcessor = function () {
|
||||||
|
if (!Zotero.Prefs.get('sync.fulltext.enabled')) return;
|
||||||
|
|
||||||
if (!_idleObserverIsRegistered) {
|
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"]
|
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
|
||||||
.getService(Components.interfaces.nsIIdleService);
|
.getService(Components.interfaces.nsIIdleService);
|
||||||
idleService.addIdleObserver(this.idleObserver, _idleObserverDelay);
|
idleService.addIdleObserver(this.idleObserver, _idleObserverDelay);
|
||||||
|
@ -1028,6 +1058,7 @@ Zotero.Fulltext = Zotero.FullText = new function(){
|
||||||
*/
|
*/
|
||||||
this.stopContentProcessor = function () {
|
this.stopContentProcessor = function () {
|
||||||
if (_idleObserverIsRegistered) {
|
if (_idleObserverIsRegistered) {
|
||||||
|
Zotero.debug("Stopping full-text content processor");
|
||||||
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
|
var idleService = Components.classes["@mozilla.org/widget/idleservice;1"]
|
||||||
.getService(Components.interfaces.nsIIdleService);
|
.getService(Components.interfaces.nsIIdleService);
|
||||||
idleService.removeIdleObserver(this.idleObserver, _idleObserverDelay);
|
idleService.removeIdleObserver(this.idleObserver, _idleObserverDelay);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user