MCGalaxy
MCGalaxy copied to clipboard
Back up files for bots, blockdefs, blockprops and level properties when a map gets deleted.
adding search term /deletelvl
for this issue.
Also: I'd suggest the final backup should be stored under levels/backups
the same way all the others are.
This seems to do the trick. Probably get rid of Paths.DeletedMapFile
too.
diff --git a/MCGalaxy/Levels/LevelActions.cs b/MCGalaxy/Levels/LevelActions.cs
index 3ba1dd83d..f5a028e72 100644
--- a/MCGalaxy/Levels/LevelActions.cs
+++ b/MCGalaxy/Levels/LevelActions.cs
@@ -153,23 +153,14 @@ namespace MCGalaxy
"A game may currently be running on it.");
return false;
}
-
- p.Message("Created backup.");
- if (!Directory.Exists("levels/deleted"))
- Directory.CreateDirectory("levels/deleted");
-
- if (File.Exists(Paths.DeletedMapFile(map))) {
- int num = 0;
- while (File.Exists(Paths.DeletedMapFile(map + num))) num++;
- File.Move(LevelInfo.MapPath(map), Paths.DeletedMapFile(map + num));
- } else {
- File.Move(LevelInfo.MapPath(map), Paths.DeletedMapFile(map));
- }
+ string backup = LevelInfo.NextBackup(map);
+ Backup(map, backup);
DoAll(map, "", action_delete);
DeleteDatabaseTables(map);
BlockDBFile.DeleteBackingFile(map);
+ File.Delete(LevelInfo.MapPath(map));
OnLevelDeletedEvent.Call(map);
return true;
}