mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Improve logging for deleteMatchingSubtitles
This works on debug but not prerelease so I am adding more logging to try and figure out why here
This commit is contained in:
parent
fcac19737c
commit
c32bb510ba
1 changed files with 16 additions and 2 deletions
|
@ -2,8 +2,10 @@ package com.lagradost.cloudstream3.utils
|
|||
|
||||
import android.content.Context
|
||||
import com.lagradost.api.Log
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getFolder
|
||||
import com.lagradost.safefile.SafeFile
|
||||
import java.io.IOException
|
||||
|
||||
object SubtitleUtils {
|
||||
|
||||
|
@ -21,8 +23,20 @@ object SubtitleUtils {
|
|||
getFolder(context, relative, info.basePath)?.forEach { (name, uri) ->
|
||||
if (isMatchingSubtitle(name, display, cleanDisplay)) {
|
||||
val subtitleFile = SafeFile.fromUri(context, uri)
|
||||
if (subtitleFile == null || !subtitleFile.delete()) {
|
||||
Log.e("SubtitleDeletion", "Failed to delete subtitle file: ${subtitleFile?.name()}")
|
||||
try {
|
||||
subtitleFile?.deleteOrThrow()
|
||||
if (subtitleFile == null) {
|
||||
Log.e(
|
||||
"SubtitleDeletion",
|
||||
"Failed to delete unknown subtitle file"
|
||||
)
|
||||
}
|
||||
} catch (ex: IOException) {
|
||||
Log.e(
|
||||
"SubtitleDeletion",
|
||||
"Failed to delete subtitle file: ${subtitleFile?.name()}"
|
||||
)
|
||||
logError(ex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue