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