More rename downloaded chapter tweaks
This commit is contained in:
parent
d7f3b399f4
commit
589464d723
@ -251,20 +251,17 @@ class DownloadManager(/* SY private */ val context: Context) {
|
||||
* @param newChapter the target chapter with the new name.
|
||||
*/
|
||||
fun renameChapter(source: Source, manga: Manga, oldChapter: Chapter, newChapter: Chapter) {
|
||||
val oldName = provider.getValidChapterDirNames(oldChapter)
|
||||
val oldNames = provider.getValidChapterDirNames(oldChapter)
|
||||
val newName = provider.getChapterDirName(newChapter)
|
||||
val mangaDir = provider.getMangaDir(manga, source)
|
||||
|
||||
var oldFolder: UniFile? = null
|
||||
val oldFolderName = oldName.find {
|
||||
oldFolder = mangaDir.findFile(it)
|
||||
oldFolder != null
|
||||
}
|
||||
// There should only be one folder with the chapter
|
||||
val oldFolder = oldNames.mapNotNull { mangaDir.findFile(it) }.firstOrNull()
|
||||
if (oldFolder?.renameTo(newName) == true) {
|
||||
cache.removeChapter(oldChapter, manga)
|
||||
cache.addChapter(newName, mangaDir, manga)
|
||||
} else {
|
||||
Timber.e("Could not rename downloaded chapter: %s.", oldFolderName)
|
||||
Timber.e("Could not rename downloaded chapter: %s.", oldNames.joinToString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user