Skip to content

Commit

Permalink
other bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
birabittoh committed Dec 22, 2023
1 parent 79e63cd commit e93f6fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions artbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"))
Expand Down
8 changes: 4 additions & 4 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ 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
}

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}
Expand All @@ -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)
Expand All @@ -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}
Expand Down

0 comments on commit e93f6fa

Please sign in to comment.