[Android] SubDownload: add error logs for DownloadSuccessful
Duncan McNamara
git at videolan.org
Thu Feb 13 09:37:09 UTC 2025
vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Thu Feb 6 16:46:45 2025 +0100| [3c57ed83089c8ddba66071f06b7a9559f170cd01] | committer: Nicolas Pomepuy
SubDownload: add error logs for DownloadSuccessful
> https://code.videolan.org/videolan/vlc-android/commit/3c57ed83089c8ddba66071f06b7a9559f170cd01
---
.../src/org/videolan/vlc/util/VLCDownloadManager.kt | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
index 457ef7628d..e1c06afa57 100644
--- a/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
+++ b/application/vlc-android/src/org/videolan/vlc/util/VLCDownloadManager.kt
@@ -33,6 +33,7 @@ object VLCDownloadManager: BroadcastReceiver(), DefaultLifecycleObserver {
private val downloadManager = AppContextProvider.appContext.getSystemService<DownloadManager>()!!
private var dlDeferred : CompletableDeferred<SubDlResult>? = null
private lateinit var defaultSubsDirectory : String
+ private val TAG = this::class.java.name
override fun onReceive(context: Context, intent: Intent?) {
intent?.run {
@@ -96,7 +97,8 @@ object VLCDownloadManager: BroadcastReceiver(), DefaultLifecycleObserver {
FileUtils.copyFile(localUri, "$extractDirectory/${subtitleItem.fileName}")?.let {dest ->
subtitleItem.run {
ExternalSubRepository.getInstance(context).removeDownloadingItem(id)
- if (Extensions.SUBTITLES.contains(".${dest.split('.').last()}")) {
+ val fileExtention = ".${dest.split('.').last()}"
+ if (Extensions.SUBTITLES.contains(fileExtention)) {
ExternalSubRepository.getInstance(context).saveDownloadedSubtitle(
idSubtitle,
dest,
@@ -106,12 +108,16 @@ object VLCDownloadManager: BroadcastReceiver(), DefaultLifecycleObserver {
hearingImpaired
)
}
- else
- Toast.makeText(context, R.string.subtitles_download_failed, Toast.LENGTH_SHORT).show()
+ else {
+ Log.e(TAG, "downloadSuccessful: Bad subtitle extension: $fileExtention")
+ Toast.makeText(context, R.string.subtitles_download_failed, Toast.LENGTH_SHORT)
+ .show()
+ }
}
withContext(Dispatchers.IO) { FileUtils.deleteFile(localUri) }
} ?: run {
+ Log.e(TAG, "downloadSuccessful: Failed to copy subtitle file")
ExternalSubRepository.getInstance(context).removeDownloadingItem(id)
Toast.makeText(context, R.string.subtitles_download_failed, Toast.LENGTH_SHORT).show()
}
More information about the Android
mailing list