From 7696ae5057803059f8301de47ec3902ce5959daf Mon Sep 17 00:00:00 2001 From: TechnicJelle <22576047+TechnicJelle@users.noreply.github.com> Date: Tue, 3 Sep 2024 05:44:47 +0200 Subject: [PATCH] When map is renamed, also rename the map data directory --- lib/config_tree.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/config_tree.dart b/lib/config_tree.dart index 0388bdc..aa0dbcc 100644 --- a/lib/config_tree.dart +++ b/lib/config_tree.dart @@ -71,6 +71,16 @@ class _ConfigTreeState extends ConsumerState { 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();