mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
fix: metadata not updated when remote file changes (#297)
This commit is contained in:
parent
cc26be0f1d
commit
0d4856c4b1
@ -84,9 +84,16 @@ func fetchRemoteImg(url string, subdir string) config.MetaFile {
|
|||||||
localRawImagePath := path.Join(config.RemoteRaw, subdir, metadata.Id)
|
localRawImagePath := path.Join(config.RemoteRaw, subdir, metadata.Id)
|
||||||
|
|
||||||
if !helper.ImageExists(localRawImagePath) || metadata.Checksum != helper.HashString(etag) {
|
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+"*"))
|
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)
|
downloadFile(localRawImagePath, url)
|
||||||
}
|
}
|
||||||
return metadata
|
return metadata
|
||||||
|
Loading…
x
Reference in New Issue
Block a user