-
Notifications
You must be signed in to change notification settings - Fork 198
Added option to stop and resume download #732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,7 +36,7 @@ Page { | |||||||||||||||||||||||||
| qsTr("%1 Successfully Written").arg(file) | ||||||||||||||||||||||||||
| else if (currentStatus === Units.DownloadStatus.Writing) | ||||||||||||||||||||||||||
| qsTr("Writing %1").arg(file) | ||||||||||||||||||||||||||
| else if (currentStatus === Units.DownloadStatus.Downloading) | ||||||||||||||||||||||||||
| else if (currentStatus === Units.DownloadStatus.Downloading || currentStatus === Units.DownloadStatus.Paused) | ||||||||||||||||||||||||||
| qsTr("Downloading %1").arg(file) | ||||||||||||||||||||||||||
| else if (currentStatus === Units.DownloadStatus.Preparing) | ||||||||||||||||||||||||||
| qsTr("Preparing %1").arg(file) | ||||||||||||||||||||||||||
|
|
@@ -78,12 +78,12 @@ Page { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| QQC2.Label { | ||||||||||||||||||||||||||
| visible: currentStatus == Units.DownloadStatus.Downloading | ||||||||||||||||||||||||||
| visible: currentStatus == Units.DownloadStatus.Downloading || currentStatus == Units.DownloadStatus.Paused | ||||||||||||||||||||||||||
| text: downloadPage.leftStr | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| QQC2.Label { | ||||||||||||||||||||||||||
| visible: currentStatus == Units.DownloadStatus.Downloading | ||||||||||||||||||||||||||
| visible: currentStatus == Units.DownloadStatus.Downloading || currentStatus == Units.DownloadStatus.Paused | ||||||||||||||||||||||||||
| text: downloadPage.rightStr | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
@@ -228,16 +228,25 @@ Page { | |||||||||||||||||||||||||
| releases.variant | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| State { | ||||||||||||||||||||||||||
| name: "paused" | ||||||||||||||||||||||||||
| when: currentStatus === Units.DownloadStatus.Paused | ||||||||||||||||||||||||||
| PropertyChanges { | ||||||||||||||||||||||||||
| target: progressBar; | ||||||||||||||||||||||||||
| value: releases.variant.progress.ratio | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // There will be only [Finish] button on the right side so [Cancel] button | ||||||||||||||||||||||||||
| // is not necessary | ||||||||||||||||||||||||||
| previousButtonVisible: currentStatus != Units.DownloadStatus.Finished | ||||||||||||||||||||||||||
| previousButtonText: qsTr("Cancel") | ||||||||||||||||||||||||||
| previousButtonText: { | ||||||||||||||||||||||||||
| return qsTr("Cancel") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| onPreviousButtonClicked: { | ||||||||||||||||||||||||||
| if (releases.variant.status === Units.DownloadStatus.Write_Verifying || | ||||||||||||||||||||||||||
| releases.variant.status === Units.DownloadStatus.Writing || | ||||||||||||||||||||||||||
| releases.variant.status === Units.DownloadStatus.Paused || | ||||||||||||||||||||||||||
| releases.variant.status === Units.DownloadStatus.Downloading || | ||||||||||||||||||||||||||
| releases.variant.status === Units.DownloadStatus.Download_Verifying) { | ||||||||||||||||||||||||||
| cancelDialog.show() | ||||||||||||||||||||||||||
|
|
@@ -249,7 +258,10 @@ Page { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| nextButtonVisible: { | ||||||||||||||||||||||||||
| if (currentStatus == Units.DownloadStatus.Finished) | ||||||||||||||||||||||||||
| // This will be [Resume] or [Pause] button to finish download or resume download | ||||||||||||||||||||||||||
| if (currentStatus == Units.DownloadStatus.Finished || | ||||||||||||||||||||||||||
| currentStatus == Units.DownloadStatus.Paused || | ||||||||||||||||||||||||||
| currentStatus == Units.DownloadStatus.Downloading) | ||||||||||||||||||||||||||
| return true | ||||||||||||||||||||||||||
|
Comment on lines
+261
to
265
|
||||||||||||||||||||||||||
| // This will be [Resume] or [Pause] button to finish download or resume download | |
| if (currentStatus == Units.DownloadStatus.Finished || | |
| currentStatus == Units.DownloadStatus.Paused || | |
| currentStatus == Units.DownloadStatus.Downloading) | |
| return true | |
| // This will be [Finish] button once the download and write process is completed | |
| if (currentStatus == Units.DownloadStatus.Finished) | |
| return true | |
| // This will be [Resume] or [Pause] button to resume or temporarily stop an in-progress download | |
| else if (currentStatus == Units.DownloadStatus.Paused || | |
| currentStatus == Units.DownloadStatus.Downloading) | |
| return true |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When resuming from a paused state, the code attempts to write to a drive even if the download hasn't completed yet. The resume logic should first complete the download before attempting to write. The current implementation will call both download() and write() simultaneously, which could cause unexpected behavior. Consider only calling download() when resuming from PAUSED status, and let the normal flow handle writing once the download is complete and the status becomes READY.
| if (selectedOption != Units.MainSelect.Write) | |
| releases.variant.download() | |
| if (drives.length) { | |
| drives.selected.setImage(releases.variant) | |
| drives.selected.write(releases.variant) | |
| } | |
| if (selectedOption != Units.MainSelect.Write) | |
| releases.variant.download() | |
| // When resuming from Paused, only resume download. | |
| // Writing will be handled by the normal flow once status is Ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previousButtonText is wrapped in a function that simply returns a constant string. This can be simplified to just assign the string directly without a function wrapper.