do not rebuild db if no new file

This commit is contained in:
thuanle
2024-07-24 08:25:09 +07:00
parent d4d38b478b
commit 71ceabdf00

View File

@@ -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"))