Skip to content

Commit

Permalink
fix: metadata not updated when remote file changes (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
HolgerHuo authored Nov 23, 2023
1 parent cc26be0 commit 0d4856c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions handler/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,16 @@ func fetchRemoteImg(url string, subdir string) config.MetaFile {
localRawImagePath := path.Join(config.RemoteRaw, subdir, metadata.Id)

if !helper.ImageExists(localRawImagePath) || metadata.Checksum != helper.HashString(etag) {
// remote file has changed or local file not exists
log.Info("Remote file not found in remote-raw, re-fetching...")
cleanProxyCache(path.Join(config.Config.ExhaustPath, subdir, metadata.Id+"*"))
if metadata.Checksum != helper.HashString(etag) {
// remote file has changed
log.Info("Remote file changed, updating metadata and fetching image source...")
helper.DeleteMetadata(url, subdir)
helper.WriteMetadata(url, etag, subdir)
} else {
// local file not exists
log.Info("Remote file not found in remote-raw, re-fetching...")
}
downloadFile(localRawImagePath, url)
}
return metadata
Expand Down

0 comments on commit 0d4856c

Please sign in to comment.