do not rebuild db if no new file
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package db_updater
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/rs/zerolog/log"
|
||||
"net/http"
|
||||
@@ -31,8 +30,13 @@ func download(url string) bool {
|
||||
|
||||
switch resp.StatusCode() {
|
||||
case http.StatusNotModified:
|
||||
fmt.Printf("No update needed: %v\n", resp.Status())
|
||||
return true
|
||||
log.Info().
|
||||
Str("url", url).
|
||||
Str("etag", etag).
|
||||
Int("status_code", resp.StatusCode()).
|
||||
Str("status", resp.Status()).
|
||||
Msg("No update needed")
|
||||
return false
|
||||
case http.StatusOK:
|
||||
_ = writeFileSByte(filename, resp.Body())
|
||||
_ = writeFileString(filenameEtag, resp.Header().Get("Etag"))
|
||||
|
||||
Reference in New Issue
Block a user