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:
Luna712 2024-08-08 15:14:08 -06:00 committed by GitHub
parent fcac19737c
commit c32bb510ba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,8 +2,10 @@ package com.lagradost.cloudstream3.utils
import android.content.Context import android.content.Context
import com.lagradost.api.Log import com.lagradost.api.Log
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getFolder import com.lagradost.cloudstream3.utils.VideoDownloadManager.getFolder
import com.lagradost.safefile.SafeFile import com.lagradost.safefile.SafeFile
import java.io.IOException
object SubtitleUtils { object SubtitleUtils {
@ -21,8 +23,20 @@ object SubtitleUtils {
getFolder(context, relative, info.basePath)?.forEach { (name, uri) -> getFolder(context, relative, info.basePath)?.forEach { (name, uri) ->
if (isMatchingSubtitle(name, display, cleanDisplay)) { if (isMatchingSubtitle(name, display, cleanDisplay)) {
val subtitleFile = SafeFile.fromUri(context, uri) val subtitleFile = SafeFile.fromUri(context, uri)
if (subtitleFile == null || !subtitleFile.delete()) { try {
Log.e("SubtitleDeletion", "Failed to delete subtitle file: ${subtitleFile?.name()}") 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)
} }
} }
} }