Skip to content

Commit c0542ca

Browse files
authored
Merge pull request #1268 from thebardsrc/ok-this-time-should-really-fix-timeline-saving
ok ther actually is a copy file function, to make it atomic, didn't f…
2 parents a0abff7 + 38de3ce commit c0542ca

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

addons/dialogic/Resources/TimelineResourceSaver.gd

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,17 @@ func _save(resource: Resource, path: String = '', flags: int = 0) -> int:
6161
var check_length = file.get_length()
6262
if check_length > 0:
6363
var check_result = file.get_as_text()
64+
file = null
6465
if result == check_result:
65-
dir.remove(path)
66-
dir.rename(path.replace(".dtl", ".tmp"), path)
67-
print('[Dialogic] Completed saving timeline "' , path, '"')
66+
dir.copy(path.replace(".dtl", ".tmp"), path)
67+
file = FileAccess.open(path, FileAccess.READ)
68+
var check_result2 = file.get_as_text()
69+
if result == check_result2:
70+
print('[Dialogic] Completed saving timeline "' , path, '"')
71+
dir.remove(path.replace(".dtl", ".tmp"))
72+
else:
73+
printerr("[Dialogic] " + path + ": Overwriting .dtl file failed! Temporary file was saved as .tmp extension, please check to see if it matches your timeline, and rename to .dtl manually.")
74+
return ERR_INVALID_DATA
6875
else:
6976
printerr("[Dialogic] " + path + ": Temporary timeline file contents do not match what was written! Temporary file was saved as .tmp extension, please check to see if it matches your timeline, and rename to .dtl manually.")
7077
return ERR_INVALID_DATA

0 commit comments

Comments
 (0)