Bug 1027458 - Correctly cleanup after canceling a mozapp download. r=fabrice

This commit is contained in:
James Lal 2014-06-21 01:32:15 +02:00
Родитель 1288ff59c4
Коммит d79fec32fc
1 изменённых файлов: 24 добавлений и 1 удалений

Просмотреть файл

@ -1316,6 +1316,12 @@ this.DOMApplicationRegistry = {
return;
}
// Ensure we don't send additional errors for this download
app.isCanceling = true;
// Ensure this app can be downloaded again after canceling
app.downloading = false;
this._saveApps().then(() => {
this.broadcastMessage("Webapps:UpdateState", {
app: {
@ -1339,6 +1345,7 @@ this.DOMApplicationRegistry = {
let id = this._appIdForManifestURL(aManifestURL);
let app = this.webapps[id];
if (!app) {
debug("startDownload: No app found for " + aManifestURL);
throw new Error("NO_SUCH_APP");
@ -2770,6 +2777,14 @@ this.DOMApplicationRegistry = {
// initialize the progress to 0 right now
oldApp.progress = 0;
// Save the current state of the app to handle cases where we may be
// retrying a past download.
yield DOMApplicationRegistry._saveApps();
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
app: oldApp,
manifestURL: aNewApp.manifestURL
});
let zipFile = yield this._getPackage(requestChannel, id, oldApp, aNewApp);
let hash = yield this._computeFileHash(zipFile.path);
@ -4083,6 +4098,15 @@ AppcacheObserver.prototype = {
let setError = function appObs_setError(aError) {
debug("Offlinecache setError to " + aError);
app.downloading = false;
mustSave = true;
// If we are canceling the download, we already send a DOWNLOAD_CANCELED
// error.
if (app.isCanceling) {
delete app.isCanceling;
return;
}
DOMApplicationRegistry.broadcastMessage("Webapps:UpdateState", {
app: app,
error: aError,
@ -4092,7 +4116,6 @@ AppcacheObserver.prototype = {
eventType: "downloaderror",
manifestURL: app.manifestURL
});
mustSave = true;
}
switch (aState) {