Clean up metacache saver (#13225)

Don't report success before the listing has actually finished. 
This will make stop conditions more clear.
This commit is contained in:
Klaus Post 2021-09-16 13:35:25 -07:00 committed by GitHub
parent 45bcf73185
commit d80826b05d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 15 deletions

View File

@ -720,26 +720,23 @@ func (er *erasureObjects) saveMetaCacheStream(ctx context.Context, mc *metaCache
return nil
})
metaMu.Lock()
// Blocks while consuming entries or an error occurs.
err = bw.Close()
if err != nil {
mc.setErr(err.Error())
return
}
metaMu.Lock()
defer metaMu.Unlock()
if mc.meta.error != "" {
return err
}
// Save success
if mc.meta.error == "" {
mc.meta.status = scanStateSuccess
mc.meta.status = scanStateSuccess
meta, err := o.updateMetacacheListing(*mc.meta, rpc)
if err == nil {
*mc.meta = meta
}
meta := *mc.meta
meta, _ = o.updateMetacacheListing(meta, rpc)
*mc.meta = meta
metaMu.Unlock()
if err := bw.Close(); err != nil {
mc.setErr(err.Error())
}
return
return nil
}
type listPathRawOptions struct {