fix: metadata not updated when remote file changes (#297)

This commit is contained in:
HolgerHuo 2023-11-23 00:38:50 -08:00 committed by GitHub
parent cc26be0f1d
commit 0d4856c4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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