Make the rename function do less lookups

This commit is contained in:
Jobobby04 2020-07-24 22:41:07 -04:00
parent 646aeb66c5
commit d7f3b399f4

View File

@ -255,8 +255,11 @@ class DownloadManager(/* SY private */ val context: Context) {
val newName = provider.getChapterDirName(newChapter)
val mangaDir = provider.getMangaDir(manga, source)
val oldFolderName = oldName.find { mangaDir.findFile(it) != null }
val oldFolder = mangaDir.findFile(oldFolderName)
var oldFolder: UniFile? = null
val oldFolderName = oldName.find {
oldFolder = mangaDir.findFile(it)
oldFolder != null
}
if (oldFolder?.renameTo(newName) == true) {
cache.removeChapter(oldChapter, manga)
cache.addChapter(newName, mangaDir, manga)