Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2b15d99a authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Recreate interrupted download when it is resumed

When a download is canceled, finishes, or is interrupted (e.g. loss of network connection)
we finish the KJob to remove it from notification area.

However, when a job was interrupted and is then resumed, the download ID is reused by the
browser and we only get sent updates for a job we no longer have.

When we get a change event from interrupted to in_progress just pretend a new download
was created and carry on as normal.

BUG: 401038

Differential Revision: https://phabricator.kde.org/D16888
parent 7bb04c74
......@@ -436,6 +436,21 @@ chrome.downloads.onChanged.addListener(function (delta) {
return;
}
// An interrupted download was resumed. When a download is interrupted, we finish (and delete)
// the job but the browser re-uses the existing download, so when this happen,
// pretend a new download was created.
if (delta.state) {
if (delta.state.previous === "interrupted" && delta.state.current === "in_progress") {
console.log("Resuming previously interrupted download, pretending a new download was created");
chrome.downloads.search({
id: delta.id
}, function (downloads) {
createDownload(downloads[0]);
});
return;
}
}
var payload = {};
whitelistedDownloadProperties.forEach(function (item) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment