mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Fix race condition
This commit is contained in:
parent
284b7df4d7
commit
78734fbb13
1 changed files with 3 additions and 1 deletions
|
@ -1794,12 +1794,14 @@ object VideoDownloadManager {
|
||||||
private fun deleteFile(context: Context, id: Int): Boolean {
|
private fun deleteFile(context: Context, id: Int): Boolean {
|
||||||
val info =
|
val info =
|
||||||
context.getKey<DownloadedFileInfo>(KEY_DOWNLOAD_INFO, id.toString()) ?: return false
|
context.getKey<DownloadedFileInfo>(KEY_DOWNLOAD_INFO, id.toString()) ?: return false
|
||||||
|
val file = info.toFile(context)
|
||||||
|
|
||||||
downloadEvent.invoke(id to DownloadActionType.Stop)
|
downloadEvent.invoke(id to DownloadActionType.Stop)
|
||||||
downloadProgressEvent.invoke(Triple(id, 0, 0))
|
downloadProgressEvent.invoke(Triple(id, 0, 0))
|
||||||
downloadStatusEvent.invoke(id to DownloadType.IsStopped)
|
downloadStatusEvent.invoke(id to DownloadType.IsStopped)
|
||||||
downloadDeleteEvent.invoke(id)
|
downloadDeleteEvent.invoke(id)
|
||||||
|
|
||||||
val isFileDeleted = info.toFile(context)?.delete() ?: false
|
val isFileDeleted = file?.delete() == true || file?.exists() == false
|
||||||
if (isFileDeleted) deleteMatchingSubtitles(context, info)
|
if (isFileDeleted) deleteMatchingSubtitles(context, info)
|
||||||
|
|
||||||
return isFileDeleted
|
return isFileDeleted
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue