Fix style installation from file
This commit is contained in:
parent
ba1285fdef
commit
0ce45103bb
1 changed files with 11 additions and 11 deletions
|
@ -246,17 +246,17 @@ Zotero.Styles = new function() {
|
||||||
this.install = Zotero.Promise.coroutine(function* (style, origin) {
|
this.install = Zotero.Promise.coroutine(function* (style, origin) {
|
||||||
var styleInstalled;
|
var styleInstalled;
|
||||||
|
|
||||||
if(style instanceof Components.interfaces.nsIFile) {
|
try {
|
||||||
// handle nsIFiles
|
if (style instanceof Components.interfaces.nsIFile) {
|
||||||
var url = Services.io.newFileURI(style);
|
// handle nsIFiles
|
||||||
styleInstalled = Zotero.HTTP.promise("GET", url.spec).when(function(xmlhttp) {
|
var url = Services.io.newFileURI(style);
|
||||||
return _install(xmlhttp.responseText, style.leafName);
|
var xmlhttp = yield Zotero.HTTP.request("GET", url.spec);
|
||||||
});
|
styleInstalled = yield _install(xmlhttp.responseText, style.leafName);
|
||||||
} else {
|
} else {
|
||||||
styleInstalled = _install(style, origin);
|
styleInstalled = yield _install(style, origin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
styleInstalled.catch(function(error) {
|
|
||||||
// Unless user cancelled, show an alert with the error
|
// Unless user cancelled, show an alert with the error
|
||||||
if(typeof error === "object" && error instanceof Zotero.Exception.UserCancelled) return;
|
if(typeof error === "object" && error instanceof Zotero.Exception.UserCancelled) return;
|
||||||
if(typeof error === "object" && error instanceof Zotero.Exception.Alert) {
|
if(typeof error === "object" && error instanceof Zotero.Exception.Alert) {
|
||||||
|
@ -267,7 +267,7 @@ Zotero.Styles = new function() {
|
||||||
(new Zotero.Exception.Alert("styles.install.unexpectedError",
|
(new Zotero.Exception.Alert("styles.install.unexpectedError",
|
||||||
origin, "styles.install.title", error)).present();
|
origin, "styles.install.title", error)).present();
|
||||||
}
|
}
|
||||||
}).done();
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue