1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-25 20:42:27 +01:00

Timeout loading :downloads after 10 seconds.

This commit is contained in:
Kris Maglione
2013-03-25 19:30:14 -07:00
parent 7c3b7b91f6
commit 2cd5e17472
2 changed files with 10 additions and 1 deletions

View File

@@ -155,6 +155,7 @@ dialog.notAvailable-1 = Dialog %S not available
# TODO: merge with addon.*?
download.unknownCommand = Unknown command
download.commandNotAllowed = Command not allowed
download.givingUpAfter = Giving up loading downloads after %S seconds
download.prompt.launchExecutable = This will launch an executable download. Would you like to continue? (yes/[no]/always):
download.nActive-1 = %S active

View File

@@ -13,6 +13,8 @@ lazyRequire("overlay", ["overlay"]);
Cu.import("resource://gre/modules/DownloadUtils.jsm", this);
var MAX_LOAD_TIME = 10 * 1000;
let prefix = "DOWNLOAD_";
var states = iter([v, k.slice(prefix.length).toLowerCase()]
for ([k, v] in Iterator(Ci.nsIDownloadManager))
@@ -258,9 +260,15 @@ var DownloadList = Class("DownloadList",
this.index = Array.indexOf(this.nodes.list.childNodes,
this.nodes.head);
let start = Date.now();
for (let row in iter(services.downloadManager.DBConnection
.createStatement("SELECT id FROM moz_downloads")))
.createStatement("SELECT id FROM moz_downloads"))) {
if (Date.now() - start > MAX_LOAD_TIME) {
util.dactyl.warn(_("download.givingUpAfter", (Date.now() - start) / 1000));
break;
}
this.addDownload(row.id);
}
this.update();
util.addObserver(this);