Fix Mod unpack folder move (#5346)

* Fix Mod unpack folder move

* Fix Mod unpack folder move - comment
This commit is contained in:
SomeTroglodyte 2021-09-29 11:34:58 +02:00 committed by GitHub
parent bb5825a325
commit 4c87d98aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}