mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 18:15:01 +02:00
Update:More accurate progress percentage using bytes, download 1 audio file at a time & currently downloading page #251 #360 #515 #274
This commit is contained in:
parent
69171e5732
commit
8bab4ae383
9 changed files with 161 additions and 106 deletions
|
@ -108,6 +108,31 @@ export const mutations = {
|
|||
state.itemDownloads.push(downloadItem)
|
||||
}
|
||||
},
|
||||
updateDownloadItemPart(state, downloadItemPart) {
|
||||
const downloadItem = state.itemDownloads.find(i => i.id == downloadItemPart.downloadItemId)
|
||||
if (!downloadItem) {
|
||||
console.error('updateDownloadItemPart: Download item not found for itemPart', JSON.stringify(downloadItemPart))
|
||||
return
|
||||
}
|
||||
|
||||
let totalBytes = 0
|
||||
let totalBytesDownloaded = 0
|
||||
downloadItem.downloadItemParts = downloadItem.downloadItemParts.map(dip => {
|
||||
let newDip = dip.id == downloadItemPart.id ? downloadItemPart : dip
|
||||
|
||||
totalBytes += newDip.fileSize
|
||||
totalBytesDownloaded += newDip.bytesDownloaded
|
||||
|
||||
return newDip
|
||||
})
|
||||
|
||||
if (totalBytes > 0) {
|
||||
downloadItem.itemProgress = Math.min(1, totalBytesDownloaded / totalBytes)
|
||||
console.log(`updateDownloadItemPart: filename=${downloadItemPart.filename}, totalBytes=${totalBytes}, downloaded=${totalBytesDownloaded}, itemProgress=${downloadItem.itemProgress}`)
|
||||
} else {
|
||||
downloadItem.itemProgress = 0
|
||||
}
|
||||
},
|
||||
removeItemDownload(state, id) {
|
||||
state.itemDownloads = state.itemDownloads.filter(i => i.id != id)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue