Tweaks based on comments in the PR

This commit is contained in:
Jobobby04 2020-07-24 22:16:23 -04:00
parent 75e9911317
commit 80394dab4a
2 changed files with 5 additions and 4 deletions

View File

@ -194,7 +194,7 @@ class DownloadCache(
val chapterDirName = provider.getValidChapterDirNames(chapter) val chapterDirName = provider.getValidChapterDirNames(chapter)
chapterDirName.forEach { chapterDirName.forEach {
if (it in mangaDir.files) { if (it in mangaDir.files) {
mangaDir.files -= chapterDirName mangaDir.files -= it
} }
} }
} }
@ -213,7 +213,7 @@ class DownloadCache(
val chapterDirName = provider.getValidChapterDirNames(chapter) val chapterDirName = provider.getValidChapterDirNames(chapter)
chapterDirName.forEach { chapterDirName.forEach {
if (it in mangaDir.files) { if (it in mangaDir.files) {
mangaDir.files -= chapterDirName mangaDir.files -= it
} }
} }
} }

View File

@ -255,12 +255,13 @@ class DownloadManager(/* SY private */ val context: Context) {
val newName = provider.getChapterDirName(newChapter) val newName = provider.getChapterDirName(newChapter)
val mangaDir = provider.getMangaDir(manga, source) val mangaDir = provider.getMangaDir(manga, source)
val oldFolder = mangaDir.findFile(oldName.find { mangaDir.findFile(it) != null }) val oldFolderName = oldName.find { mangaDir.findFile(it) != null }
val oldFolder = mangaDir.findFile(oldFolderName)
if (oldFolder?.renameTo(newName) == true) { if (oldFolder?.renameTo(newName) == true) {
cache.removeChapter(oldChapter, manga) cache.removeChapter(oldChapter, manga)
cache.addChapter(newName, mangaDir, manga) cache.addChapter(newName, mangaDir, manga)
} else { } else {
Timber.e("Could not rename downloaded chapter: %s.", oldName.last()) Timber.e("Could not rename downloaded chapter: %s.", oldFolderName)
} }
} }
} }