From 79cd35b29a4852f65bf29bf24a6e097cdeb6a492 Mon Sep 17 00:00:00 2001 From: Quickdev Date: Thu, 29 Aug 2024 13:58:43 +0530 Subject: [PATCH] feat(downloader): Copy the file location when using ext downloader (#1758) --- .../tachiyomi/data/download/anime/AnimeDownloader.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt index c8a2640b16..239c6f63df 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/anime/AnimeDownloader.kt @@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.network.ProgressListener import eu.kanade.tachiyomi.util.size import eu.kanade.tachiyomi.util.storage.DiskUtil import eu.kanade.tachiyomi.util.storage.toFFmpegString +import eu.kanade.tachiyomi.util.system.copyToClipboard import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job @@ -1158,7 +1159,8 @@ class AnimeDownloader( filename: String, ): UniFile { try { - val file = tmpDir.createFile("$filename.mp4")!! + val file = tmpDir.createFile("${filename}_tmp.mp4")!! + context.copyToClipboard("Episode download location", tmpDir.filePath!!.substringBeforeLast("_tmp")) // TODO: support other file formats!! // start download with intent @@ -1231,7 +1233,7 @@ class AnimeDownloader( context.startActivity(intent) return file } catch (e: Exception) { - tmpDir.findFile("$filename.mp4")?.delete() + tmpDir.findFile("${filename}_tmp.mp4")?.delete() throw e } } @@ -1255,6 +1257,8 @@ class AnimeDownloader( download.status = if (downloadedVideo.size == 1) { // Only rename the directory if it's downloaded + val filename = DiskUtil.buildValidFilename("${download.anime.title} - ${download.episode.name}") + tmpDir.findFile("${filename}_tmp.mp4")?.delete() tmpDir.renameTo(dirname) cache.addEpisode(dirname, animeDir, download.anime)