Make Zotero.Styles/Translators.init() wait until bundled files are updated
Fixes #1123, Quick Copy error in console with new data directory
This commit is contained in:
parent
c6a2057340
commit
d88cfc6c5f
2 changed files with 18 additions and 5 deletions
|
@ -465,17 +465,17 @@ Zotero.Schema = new function(){
|
||||||
// Update files
|
// Update files
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'styles':
|
case 'styles':
|
||||||
yield Zotero.Styles.init();
|
yield Zotero.Styles.reinit({ fromSchemaUpdate: true, noReinit: true });
|
||||||
var updated = yield _updateBundledFilesAtLocation(installLocation, mode);
|
var updated = yield _updateBundledFilesAtLocation(installLocation, mode);
|
||||||
|
|
||||||
case 'translators':
|
case 'translators':
|
||||||
yield Zotero.Translators.init();
|
yield Zotero.Translators.reinit({ fromSchemaUpdate: true, noReinit: true });
|
||||||
var updated = yield _updateBundledFilesAtLocation(installLocation, mode);
|
var updated = yield _updateBundledFilesAtLocation(installLocation, mode);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
yield Zotero.Translators.init();
|
yield Zotero.Translators.reinit({ fromSchemaUpdate: true, noReinit: true });
|
||||||
let up1 = yield _updateBundledFilesAtLocation(installLocation, 'translators', true);
|
let up1 = yield _updateBundledFilesAtLocation(installLocation, 'translators', true);
|
||||||
yield Zotero.Styles.init();
|
yield Zotero.Styles.reinit({ fromSchemaUpdate: true, noReinit: true });
|
||||||
let up2 = yield _updateBundledFilesAtLocation(installLocation, 'styles');
|
let up2 = yield _updateBundledFilesAtLocation(installLocation, 'styles');
|
||||||
var updated = up1 || up2;
|
var updated = up1 || up2;
|
||||||
}
|
}
|
||||||
|
@ -952,7 +952,8 @@ Zotero.Schema = new function(){
|
||||||
});
|
});
|
||||||
|
|
||||||
yield Zotero[Mode].reinit({
|
yield Zotero[Mode].reinit({
|
||||||
metadataCache: cache
|
metadataCache: cache,
|
||||||
|
fromSchemaUpdate: true
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -43,6 +43,18 @@ Zotero.Translators = new function() {
|
||||||
* available (e.g., in updateBundledFiles()), to avoid unnecesary file reads
|
* available (e.g., in updateBundledFiles()), to avoid unnecesary file reads
|
||||||
*/
|
*/
|
||||||
this.reinit = Zotero.Promise.coroutine(function* (options = {}) {
|
this.reinit = Zotero.Promise.coroutine(function* (options = {}) {
|
||||||
|
// Wait until bundled files have been updated, except when this is called by the schema update
|
||||||
|
// code itself
|
||||||
|
if (!options.fromSchemaUpdate) {
|
||||||
|
yield Zotero.Schema.schemaUpdatePromise;
|
||||||
|
}
|
||||||
|
// Before bundled files can be updated, any existing translators need to be loaded, but other
|
||||||
|
// init() calls from elsewhere should still wait on schemaUpdatePromise, so init()/lazy()
|
||||||
|
// can't be used. Instead, the schema update code calls reinit() with noReinit.
|
||||||
|
else if (options.noReinit && _initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.debug("Initializing translators");
|
Zotero.debug("Initializing translators");
|
||||||
var start = new Date;
|
var start = new Date;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue