fix crash on save

This commit is contained in:
lunarcleint
2025-03-08 22:49:10 -07:00
parent 39aadbe8a0
commit d15e100b53
+2 -2
View File
@@ -125,7 +125,7 @@ class Charter extends UIState {
},
null,*/
{
label: "Save everything",
label: "Save",
keybind: [CONTROL, S],
onSelect: _file_save_all,
},
@@ -1457,7 +1457,7 @@ class Charter extends UIState {
var data = {events: Chart.filterChartForSaving(PlayState.SONG, false, false, true).events};
var path = '${Paths.getAssetsRoot()}/songs/${__song.toLowerCase()}/events.json';
if (data == null || data.events.length == 0) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex
if (FileSystem.exists(path) && (data.events == null || data.events.length == 0)) FileSystem.deleteFile(path); // Instead of replacing with a useless empty file, deletes the file directly - Nex
else CoolUtil.safeSaveFile(path, Json.stringify(data, null, Options.editorPrettyPrint ? Flags.JSON_PRETTY_PRINT : null));
#else
_file_events_saveas(shouldBuild);