From e93f6facc7a759881a3f2e093b267a13c8626cae Mon Sep 17 00:00:00 2001 From: Marco Andronaco Date: Fri, 22 Dec 2023 14:57:21 +0100 Subject: [PATCH] other bugfixes --- artbound.go | 4 +--- cache/cache.go | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/artbound.go b/artbound.go index fb92ecf..1b7b59f 100644 --- a/artbound.go +++ b/artbound.go @@ -67,7 +67,7 @@ func clearHandler(db *cache.DB) http.HandlerFunc { } err := db.Clear() if err != nil { - log.Fatal("Error:", err) + log.Println("Error:", err) http.Error(w, "Could not delete cache.", http.StatusInternalServerError) } http.Error(w, "Done.", http.StatusOK) @@ -132,13 +132,11 @@ func main() { spreadsheetId := os.Getenv("SPREADSHEET_ID") if spreadsheetId == "" { log.Fatal("Please fill out SPREADSHEET_ID in .env") - os.Exit(1) } spreadsheetRange := os.Getenv("SPREADSHEET_RANGE") if spreadsheetRange == "" { log.Fatal("Please fill out SPREADSHEET_RANGE in .env") - os.Exit(1) } fs := http.FileServer(http.Dir("./static")) diff --git a/cache/cache.go b/cache/cache.go index 4a7670d..163045b 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -88,7 +88,7 @@ func handleEntry(entry *Entry, db *DB) string { log.Println(entry.FileID, "is not cached. Downloading.") ext, err := getFile(&db.googleApi, entry.FileID, cachePath) if err != nil { - log.Fatal("Could not download file", entry.FileID) + log.Println("Could not download file", entry.FileID) } return ext } @@ -96,7 +96,7 @@ func handleEntry(entry *Entry, db *DB) string { func InitDB(spreadsheetId string, spreadsheetRange string) *DB { files, err := listCachedEntries(cachePath) if err != nil { - log.Fatal("Could not list cached entries.") + log.Println("Could not list cached entries.") } googleApi := initGoogleAPI(spreadsheetId, spreadsheetRange) db := &DB{time.Now(), []Entry{}, files, *googleApi} @@ -107,7 +107,7 @@ func InitDB(spreadsheetId string, spreadsheetRange string) *DB { func (db *DB) update() (error, int) { entries, err := getEntries(&db.googleApi) if err != nil { - log.Fatal("Could not update DB!", err) + log.Println("Could not update DB!", err) return err, 0 } newEntries := len(entries) - len(db.Entries) @@ -119,7 +119,7 @@ func (db *DB) update() (error, int) { func (db *DB) UpdateCall() UpdateDBPayload { err, newEntries := db.update() if err != nil { - log.Fatal("Could not update DB!", err) + log.Println("Could not update DB!", err) newEntries = 0 } return UpdateDBPayload{db.LastUpdated.Format("02/01/2006 15:04"), newEntries}