mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-15 08:23:02 -03:00
refactor: streamline download status updates in DownloadManager
This commit is contained in:
@@ -156,15 +156,20 @@ export class DownloadManager {
|
||||
const { progress, downloadSpeed, bytesDownloaded, fileSize, folderName } =
|
||||
status;
|
||||
|
||||
const updatedDownload = {
|
||||
...download,
|
||||
bytesDownloaded,
|
||||
fileSize,
|
||||
progress,
|
||||
folderName,
|
||||
status:
|
||||
status.status === "complete"
|
||||
? ("complete" as const)
|
||||
: ("active" as const),
|
||||
};
|
||||
|
||||
if (status.status === "active" || status.status === "complete") {
|
||||
await downloadsSublevel.put(downloadId, {
|
||||
...download,
|
||||
bytesDownloaded,
|
||||
fileSize,
|
||||
progress,
|
||||
folderName,
|
||||
status: status.status === "complete" ? "complete" : "active",
|
||||
});
|
||||
await downloadsSublevel.put(downloadId, updatedDownload);
|
||||
}
|
||||
|
||||
return {
|
||||
@@ -176,7 +181,7 @@ export class DownloadManager {
|
||||
isCheckingFiles: false,
|
||||
progress,
|
||||
gameId: downloadId,
|
||||
download,
|
||||
download: updatedDownload,
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error("[DownloadManager] Error getting JS download status:", err);
|
||||
|
||||
Reference in New Issue
Block a user