Skip to content

Commit

Permalink
When map is renamed, also rename the map data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
TechnicJelle committed Sep 3, 2024
1 parent e5864d5 commit 7696ae5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/config_tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ class _ConfigTreeState extends ConsumerState<ConfigTree> {
if (destination != null) {
removeMap(File(moveEvent.path));
addMap(File(destination));

final String prevMapID = p.basenameWithoutExtension(moveEvent.path);
final String nextMapID = p.basenameWithoutExtension(destination);

//Also rename the map data directory:
final Directory mapDataDir =
Directory(p.join(projectPath, "web", "maps", prevMapID));
if (mapDataDir.existsSync()) {
mapDataDir.rename(p.join(projectPath, "web", "maps", nextMapID));
}
} else {
//could not get destination, so we nuke everything and re-add it all
maps.clear();
Expand Down

0 comments on commit 7696ae5

Please sign in to comment.