Metadata support for initial creation phase.

This commit is contained in:
Tolgahan Çelik
2022-07-26 19:48:18 +03:00
parent 9ccfc3e62c
commit 0e92b36dbf
2 changed files with 12 additions and 15 deletions
+6 -10
View File
@@ -13,17 +13,13 @@ export default class DownloadTask {
metadata = {}
constructor (taskInfo, originalTask) {
if (typeof taskInfo === 'string') {
this.id = taskInfo
} else {
this.id = taskInfo.id
this.percent = taskInfo.percent
this.bytesWritten = taskInfo.bytesWritten
this.totalBytes = taskInfo.totalBytes
this.id = taskInfo.id
this.percent = taskInfo.percent ?? 0
this.bytesWritten = taskInfo.bytesWritten ?? 0
this.totalBytes = taskInfo.totalBytes ?? 0
if (this.#parseable(taskInfo.metadata)) {
this.metadata = JSON.parse(taskInfo.metadata);
}
if (this.#parseable(taskInfo.metadata)) {
this.metadata = JSON.parse(taskInfo.metadata);
}
if (originalTask) {