Handle broken cache manifest
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Elara 2023-01-28 21:05:20 -08:00
parent d26b288cde
commit 657b562f31
1 changed files with 21 additions and 14 deletions

View File

@ -91,22 +91,29 @@ func Download(ctx context.Context, opts Options) (err error) {
} }
m, err := getManifest(cacheDir) m, err := getManifest(cacheDir)
if err != nil { if err == nil {
return err t = m.Type
}
t = m.Type
dest := filepath.Join(opts.Destination, m.Name) dest := filepath.Join(opts.Destination, m.Name)
ok, err := handleCache(cacheDir, dest, t) ok, err := handleCache(cacheDir, dest, t)
if err != nil { if err != nil {
return err return err
} }
if ok && !updated { if ok && !updated {
log.Info("Source found in cache, linked to destination").Str("source", opts.Name).Stringer("type", t).Send() log.Info("Source found in cache, linked to destination").Str("source", opts.Name).Stringer("type", t).Send()
return nil return nil
} else if ok { } else if ok {
return nil return nil
}
} else {
// If we cannot read the manifest,
// this cache entry is invalid and
// the source must be re-downloaded.
err = os.RemoveAll(cacheDir)
if err != nil {
return err
}
} }
} }