Skip to content

Commit

Permalink
feat(downloader): Copy the file location when using ext downloader (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
quickdesh authored Aug 29, 2024
1 parent dabfdf9 commit 79cd35b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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)
Expand Down

0 comments on commit 79cd35b

Please sign in to comment.