Skip to content

Commit

Permalink
Remove unused moveRecursive()
Browse files Browse the repository at this point in the history
  • Loading branch information
wmontwe committed Feb 17, 2025
1 parent a11fd55 commit 750ac36
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions legacy/core/src/main/java/com/fsck/k9/helper/FileHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,54 +70,4 @@ object FileHelper {
false
}
}

@JvmStatic
fun moveRecursive(fromDir: File, toDir: File) {
if (!fromDir.exists()) {
return
}
if (!fromDir.isDirectory()) {
if (toDir.exists()) {
if (!toDir.delete()) {
Timber.w("cannot delete already existing file/directory %s", toDir.absolutePath)
}
}
if (!fromDir.renameTo(toDir)) {
Timber.w("cannot rename %s to %s - moving instead", fromDir.absolutePath, toDir.absolutePath)
move(fromDir, toDir)
}
return
}
if (!toDir.exists() || !toDir.isDirectory()) {
if (toDir.exists()) {
if (!toDir.delete()) {
Timber.d("Unable to delete file: %s", toDir.absolutePath)
}
}
if (!toDir.mkdirs()) {
Timber.w("cannot create directory %s", toDir.absolutePath)
}
}
val files = fromDir.listFiles().orEmpty()
for (file in files) {
if (file.isDirectory()) {
moveRecursive(file, File(toDir, file.getName()))
if (!file.delete()) {
Timber.d("Unable to delete file: %s", toDir.absolutePath)
}
} else {
val target = File(toDir, file.getName())
if (!file.renameTo(target)) {
Timber.w(
"cannot rename %s to %s - moving instead",
file.absolutePath, target.absolutePath,
)
move(file, target)
}
}
}
if (!fromDir.delete()) {
Timber.w("cannot delete %s", fromDir.absolutePath)
}
}
}

0 comments on commit 750ac36

Please sign in to comment.