Skip to content

Commit

Permalink
createworld: don't allow copying into pre-existing folder path
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 15, 2020
1 parent 70cd17d commit bdf79da
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -146,8 +146,8 @@ public void execute(ScriptEntry scriptEntry) {
Debug.echoError(scriptEntry.getResidingQueue(), "Invalid copy from world name!");
return false;
}
File newFolder = new File(worldName.asString());
File folder = new File(copy_from.asString().replace("w@", ""));
final File newFolder = new File(worldName.asString());
if (!Utilities.canReadFile(folder)) {
Debug.echoError("Cannot copy from that folder path.");
return false;
Expand All @@ -160,6 +160,10 @@ public void execute(ScriptEntry scriptEntry) {
Debug.echoError(scriptEntry.getResidingQueue(), "Invalid copy from world folder - does not exist!");
return false;
}
if (newFolder.exists()) {
Debug.echoError("Cannot copy to new world - that folder already exists.");
return false;
}
CoreUtilities.copyDirectory(folder, newFolder, excludedExtensionsForCopyFrom);
Debug.echoDebug(scriptEntry, "Copied " + folder.getName() + " to " + newFolder.getName());
File file = new File(worldName.asString() + "/uid.dat");
Expand Down

0 comments on commit bdf79da

Please sign in to comment.