Clean up progress logic

This commit is contained in:
ronaldheft 2022-08-06 18:31:59 -04:00
parent af2c609405
commit dc8bc2fccd
2 changed files with 27 additions and 25 deletions

View file

@ -169,15 +169,9 @@ class Database {
}
}
public func updateDownloadItemPartPercent(downloadItemPartId: String, percent: Double) {
public func updateDownloadItemPart(_ part: DownloadItemPart) {
Database.realmQueue.sync {
try! instance.write {
let part = instance.object(ofType: DownloadItemPart.self, forPrimaryKey: downloadItemPartId)
guard var part = part else {
NSLog("downloadItemPartId not found (\(downloadItemPartId)")
return
}
part.progress = percent
instance.add(part, update: .modified)
}
}