test memory: read metadata if -M flag is specified
This commit is contained in:
parent
ec3cee89d3
commit
43506f8086
1 changed files with 8 additions and 0 deletions
|
@ -29,6 +29,7 @@ var commandDefinition = &cobra.Command{
|
||||||
cmd.Run(false, false, command, func() error {
|
cmd.Run(false, false, command, func() error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ci := fs.GetConfig(context.Background())
|
ci := fs.GetConfig(context.Background())
|
||||||
|
metadata := ci.Metadata && fsrc.Features().ReadMetadata
|
||||||
objects, _, _, err := operations.Count(ctx, fsrc)
|
objects, _, _, err := operations.Count(ctx, fsrc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -39,6 +40,13 @@ var commandDefinition = &cobra.Command{
|
||||||
runtime.ReadMemStats(&before)
|
runtime.ReadMemStats(&before)
|
||||||
var mu sync.Mutex
|
var mu sync.Mutex
|
||||||
err = operations.ListFn(ctx, fsrc, func(o fs.Object) {
|
err = operations.ListFn(ctx, fsrc, func(o fs.Object) {
|
||||||
|
// Read the metadata so it gets cached in the object
|
||||||
|
if metadata {
|
||||||
|
_, err := fs.GetMetadata(ctx, o)
|
||||||
|
if err != nil {
|
||||||
|
fs.Errorf(o, "Failed to read metadata: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
objs = append(objs, o)
|
objs = append(objs, o)
|
||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
Loading…
Reference in a new issue