Add socket event to remove download, fix clearInterval on stream loop

This commit is contained in:
Mark Cooper 2021-09-12 16:10:12 -05:00
parent 80f90907d4
commit 11f4caffa8
5 changed files with 26 additions and 3 deletions

View file

@ -49,6 +49,15 @@ class DownloadManager {
this.prepareDownload(client, audiobook, options)
}
removeSocketRequest(socket, downloadId) {
var download = this.downloads.find(d => d.id === downloadId)
if (!download) {
Logger.error('Remove download request download not found ' + downloadId)
return
}
this.removeDownload(download)
}
async prepareDownload(client, audiobook, options = {}) {
var downloadId = (Math.trunc(Math.random() * 1000) + Date.now()).toString(36)
var dlpath = Path.join(this.downloadDirPath, downloadId)