Currently, when the world folder to backup is a symbolic link, shutil.rmtree in remove_worlds will raise an exception:
# symlinks to directories are forbidden, see bug #1669
raise OSError("Cannot call rmtree on a symbolic link")
This PR adds proper support for handling symbolic link by copying/removing related files recursively dereferenced from the symlink to the real folder.
This PR does not change any behavior in current QuickBackupM's implementation, since the entrypoint to added code is scoped only to symlink files by while os.path.islink(src_path).
Use case
Suppose server folder contains multiple redstone saves downloaded from internet, and MCDR instance uses a symlink folder called world / current to reference the save we want to start, so we do not need to change world_names field in every plugin's config file when switching the world to start.
Here, assume the current symlink is pointing to fortress-farm folder. With this PR, QuickBackupM will copy both current symlink and fortress-farm folder to the slot, and copying them back when recovering.
When current symlink has been switched to other worlds, behavior in this PR also implies that current symlink will switch back to the world the slot saves when recovering, which is intuitive.
Currently, when the world folder to backup is a symbolic link,
shutil.rmtree
inremove_worlds
will raise an exception:This PR adds proper support for handling symbolic link by copying/removing related files recursively dereferenced from the symlink to the real folder.
This PR does not change any behavior in current
QuickBackupM
's implementation, since the entrypoint to added code is scoped only to symlink files bywhile os.path.islink(src_path)
.Use case
Suppose
server
folder contains multiple redstone saves downloaded from internet, and MCDR instance uses a symlink folder calledworld
/current
to reference the save we want to start, so we do not need to changeworld_names
field in every plugin's config file when switching the world to start.Here, assume the
current
symlink is pointing tofortress-farm
folder. With this PR,QuickBackupM
will copy bothcurrent
symlink andfortress-farm
folder to the slot, and copying them back when recovering.When
current
symlink has been switched to other worlds, behavior in this PR also implies thatcurrent
symlink will switch back to the world the slot saves when recovering, which is intuitive.