mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
FormatConverter: Copy worlds for backup if rename fails
this can fail if the backups directory points to a different drive than the original worlds location. In this case, we have to copy and delete the files instead, which is much slower, but works. I REALLY advise against putting backups on a different mount point than worlds if you plan to convert large worlds.
This commit is contained in:
@ -91,8 +91,17 @@ class FormatConverter{
|
||||
$new->close();
|
||||
|
||||
$this->logger->info("Backing up pre-conversion world to " . $this->backupPath);
|
||||
rename($path, $this->backupPath);
|
||||
rename($new->getPath(), $path);
|
||||
if(!@rename($path, $this->backupPath)){
|
||||
$this->logger->warning("Moving old world files for backup failed, attempting copy instead. This might take a long time.");
|
||||
Filesystem::recursiveCopy($path, $this->backupPath);
|
||||
Filesystem::recursiveUnlink($path);
|
||||
}
|
||||
if(!@rename($new->getPath(), $path)){
|
||||
//we don't expect this to happen because worlds/ should most likely be all on the same FS, but just in case...
|
||||
$this->logger->debug("Relocation of new world files to location failed, attempting copy and delete instead");
|
||||
Filesystem::recursiveCopy($new->getPath(), $path);
|
||||
Filesystem::recursiveUnlink($new->getPath());
|
||||
}
|
||||
|
||||
$this->logger->info("Conversion completed");
|
||||
/**
|
||||
|
Reference in New Issue
Block a user