fix: prevent no cache file from crashing startup

Signed-off-by: cpendery <cpendery@vt.edu>
This commit is contained in:
cpendery
2023-09-18 03:34:15 -04:00
parent f145adbc60
commit 31181ba4fc
+5 -2
View File
@@ -53,7 +53,10 @@ func ClearResult() {
if err != nil {
slog.Error("failed to load cache file", slog.String("error", err.Error()))
}
if err := os.Truncate(path, 0); err != nil {
slog.Error("failed to clear cache file", slog.String("error", err.Error()))
os.Stat(path)
if _, err := os.Stat(path); err == nil {
if err := os.Truncate(path, 0); err != nil {
slog.Error("failed to clear cache file", slog.String("error", err.Error()))
}
}
}