From bf3a9a35cee224afeef0f87a30eb797489907825 Mon Sep 17 00:00:00 2001 From: Xananax Date: Fri, 10 Mar 2023 00:11:34 +0400 Subject: [PATCH] fix: do not resume if file can't be opened --- scripts/time_entry.gd | 2 +- scripts/time_sheet.gd | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/time_entry.gd b/scripts/time_entry.gd index c87f71b..87911d2 100644 --- a/scripts/time_entry.gd +++ b/scripts/time_entry.gd @@ -76,4 +76,4 @@ func from_csv_line(line: PackedStringArray) -> TimeEntry: return self func _to_string() -> String: - return "%s\t%s\t%s"%[name, Consts.ONGOING if closed == false else "", start_time] \ No newline at end of file + return "%s\t%s\t%s"%[name, Consts.ONGOING if closed == false else "", start_time] diff --git a/scripts/time_sheet.gd b/scripts/time_sheet.gd index 26ccd5f..1af5aea 100644 --- a/scripts/time_sheet.gd +++ b/scripts/time_sheet.gd @@ -43,6 +43,7 @@ func start_entry(entry_name: String) -> void: var file := FileAccess.open(source_path, FileAccess.READ_WRITE) if file == null: printerr("Could not open file") + return entries.append(current_entry) file.store_csv_line(current_entry.to_csv_line()) @@ -69,6 +70,7 @@ func save() -> void: var file := FileAccess.open(source_path, FileAccess.WRITE) if file == null: printerr("Could not open file") + return for time_entry in entries: file.store_csv_line(time_entry.to_csv_line())