Skip to content

Commit 1aab73c

Browse files
committed
Prevent bundled song copy overwriting user songs
Normalize source/destination paths and skip copying when they resolve to the same directory. Only copy bundled .nbs files if the destination file is missing (never replace existing songs) and emit a debug message when skipping self-copies. Bumped macros version to 3.12.0-beta.5 and added a changelog entry describing the fix.
1 parent 7f62a3e commit 1aab73c

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

datafiles/Data/changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
Changes in v3.12.0-beta.5 (2026.08.05):
2+
3+
* Fixed bundled song copying deleting non-demo songs from the user-data Songs
4+
directory during updates.
5+
6+
7+
18
Changes in v3.12.0-beta.4 (2026.08.05):
29

310
* Added Litematica-compatible .nbt output to schematic and track export. This

scripts/copy_bundled_files/copy_bundled_files.gml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,32 @@ function copy_bundled_file(source, destination, nocopy=0) {
1515
}
1616

1717
function copy_bundled_songs(source, destination) {
18+
var source_path = string_replace_all(source, "\\", "/")
19+
var destination_path = string_replace_all(destination, "\\", "/")
20+
if (os_type == os_windows) {
21+
source_path = string_lower(source_path)
22+
destination_path = string_lower(destination_path)
23+
}
24+
25+
// Newer runtimes can resolve working_directory to the save area. Never
26+
// enumerate and copy a Songs directory onto itself.
27+
if (source_path == destination_path) {
28+
show_debug_message("Skipped bundled song copy because source and destination are the same directory.")
29+
return
30+
}
31+
1832
if (!directory_exists(destination)) directory_create(destination)
1933

2034
var song = file_find_first(source + "*.*", 0)
2135
while (song != "") {
2236
if (string_lower(filename_ext(song)) == ".nbs") {
23-
copy_bundled_file(source + song, destination + song)
37+
var source_song = source + song
38+
var destination_song = destination + song
39+
40+
// GameMaker file searches can expose both bundled and saved files.
41+
// Existing songs may contain user work, so bundled songs only fill
42+
// missing destinations and are never allowed to replace them.
43+
if (!file_exists(destination_song)) file_copy(source_song, destination_song)
2444
}
2545
song = file_find_next()
2646
}

scripts/macros/macros.gml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function macros() {
22
#macro gm_runtime_version "2022.0.3 LTS"
33
#macro version_date "2026.8.5"
4-
#macro version "3.12.0-beta.4"
4+
#macro version "3.12.0-beta.5"
55
#macro is_prerelease 1 // remember to change to 0 in the release!
66
#macro is_development 0 // the more frequent versions that are not on github (no auto update)
77
#macro nbs_version 6

0 commit comments

Comments
 (0)