From fb38d307750a849e7c941c164a3c223d69f2cd14 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 14 May 2023 12:24:40 -0400 Subject: [PATCH] Avoid attempts to renaming download dirs if name hasn't actually changed Maybe fixes #9503 --- .../eu/kanade/tachiyomi/data/download/DownloadManager.kt | 6 +++++- .../eu/kanade/tachiyomi/source/AndroidSourceManager.kt | 2 +- data/src/main/java/tachiyomi/data/source/SourceMapper.kt | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 3630281b74..21b5814e35 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -303,9 +303,11 @@ class DownloadManager( val oldFolder = provider.findSourceDir(oldSource) ?: return val newName = provider.getSourceDirName(newSource) + if (oldFolder.name == newName) return + val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true) if (capitalizationChanged) { - val tempName = newName + "_tmp" + val tempName = newName + Downloader.TMP_DIR_SUFFIX if (oldFolder.renameTo(tempName).not()) { logcat(LogPriority.ERROR) { "Failed to rename source download folder: ${oldFolder.name}" } return @@ -339,6 +341,8 @@ class DownloadManager( newName += ".cbz" } + if (oldDownload.name == newName) return + if (oldDownload.renameTo(newName)) { cache.removeChapter(oldChapter, manga) cache.addChapter(newName, mangaDir, manga) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/AndroidSourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/AndroidSourceManager.kt index a8255ba6ec..9e45460c65 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/AndroidSourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/AndroidSourceManager.kt @@ -110,6 +110,6 @@ class AndroidSourceManager( registerStubSource(it) return it } - return StubSource(id, "", "") + return StubSource(id = id, lang = "", name = "") } } diff --git a/data/src/main/java/tachiyomi/data/source/SourceMapper.kt b/data/src/main/java/tachiyomi/data/source/SourceMapper.kt index d3bbf3f49d..8b598152e0 100644 --- a/data/src/main/java/tachiyomi/data/source/SourceMapper.kt +++ b/data/src/main/java/tachiyomi/data/source/SourceMapper.kt @@ -5,14 +5,14 @@ import tachiyomi.domain.source.model.StubSource val sourceMapper: (eu.kanade.tachiyomi.source.Source) -> Source = { source -> Source( - source.id, - source.lang, - source.name, + id = source.id, + lang = source.lang, + name = source.name, supportsLatest = false, isStub = false, ) } val sourceDataMapper: (Long, String, String) -> StubSource = { id, lang, name -> - StubSource(id, lang, name) + StubSource(id = id, lang = lang, name = name) }