mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-10 11:08:56 +01:00
Rename source download folder on source rename (#7898)
* Rename source download folder on source rename * Review Changes * Review Changes 2
This commit is contained in:
@@ -343,6 +343,30 @@ class DownloadManager(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames source download folder
|
||||
*
|
||||
* @param oldSource the old source.
|
||||
* @param newSource the new source.
|
||||
*/
|
||||
fun renameSource(oldSource: Source, newSource: Source) {
|
||||
val oldFolder = provider.findSourceDir(oldSource) ?: return
|
||||
val newName = provider.getSourceDirName(newSource)
|
||||
|
||||
val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true)
|
||||
if (capitalizationChanged) {
|
||||
val tempName = newName + "_tmp"
|
||||
if (oldFolder.renameTo(tempName).not()) {
|
||||
logcat(LogPriority.ERROR) { "Could not rename source download folder: ${oldFolder.name}." }
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (oldFolder.renameTo(newName).not()) {
|
||||
logcat(LogPriority.ERROR) { "Could not rename source download folder: ${oldFolder.name}." }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames an already downloaded chapter
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user