diff --git a/core/src/com/unciv/ui/worldscreen/mainmenu/GitHub.kt b/core/src/com/unciv/ui/worldscreen/mainmenu/GitHub.kt index dffd7845e2..7e70739846 100644 --- a/core/src/com/unciv/ui/worldscreen/mainmenu/GitHub.kt +++ b/core/src/com/unciv/ui/worldscreen/mainmenu/GitHub.kt @@ -107,10 +107,18 @@ object Github { return finalDestination } - + private fun FileHandle.renameOrMove(dest: FileHandle) { // Gdx tries a java rename for Absolute and External, but NOT for Local - rectify that - if (type() == Files.FileType.Local && file().renameTo(dest.file())) return + if (type() == Files.FileType.Local) { + // See #5346: renameTo 'unpacks' a source folder if the destination exists and is an + // empty folder, dropping the name of the source entirely. + // Safer to ask for a move to the not-yet-existing full resulting path instead. + if (isDirectory) + if (file().renameTo(dest.child(name()).file())) return + else + if (file().renameTo(dest.file())) return + } moveTo(dest) }