Show file size for uplink ls command (#344)
* Show file size for uplink ls command * align size to right * Fix stream store list method to handle meta.Size flag
This commit is contained in:
parent
10d9420f24
commit
e90c2140b8
@ -93,7 +93,7 @@ func listFiles(ctx context.Context, bs buckets.Store, u *url.URL, prependBucket
|
||||
startAfter := paths.New("")
|
||||
|
||||
for {
|
||||
items, more, err := o.List(ctx, paths.New(u.Path), startAfter, nil, *recursiveFlag, 0, meta.Modified)
|
||||
items, more, err := o.List(ctx, paths.New(u.Path), startAfter, nil, *recursiveFlag, 0, meta.Modified|meta.Size)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -106,7 +106,7 @@ func listFiles(ctx context.Context, bs buckets.Store, u *url.URL, prependBucket
|
||||
if object.IsPrefix {
|
||||
fmt.Println("PRE", path+"/")
|
||||
} else {
|
||||
fmt.Println("OBJ", formatTime(object.Meta.Modified), path)
|
||||
fmt.Printf("%v %v %12v %v\n", "OBJ", formatTime(object.Meta.Modified), object.Meta.Size, path)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
|
||||
"storj.io/storj/pkg/paths"
|
||||
ranger "storj.io/storj/pkg/ranger"
|
||||
"storj.io/storj/pkg/storage/meta"
|
||||
"storj.io/storj/pkg/storage/segments"
|
||||
streamspb "storj.io/storj/protos/streams"
|
||||
)
|
||||
@ -233,6 +234,12 @@ func (s *streamStore) List(ctx context.Context, prefix, startAfter, endBefore pa
|
||||
more bool, err error) {
|
||||
defer mon.Task()(&ctx)(&err)
|
||||
|
||||
if metaFlags&meta.Size != 0 {
|
||||
// Calculating the stream's size require also the user-defined metadata,
|
||||
// where stream store keeps info about the number of segments and their size.
|
||||
metaFlags |= meta.UserDefined
|
||||
}
|
||||
|
||||
segments, more, err := s.segments.List(ctx, prefix.Prepend("l"), startAfter, endBefore, recursive, limit, metaFlags)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
|
Loading…
Reference in New Issue
Block a user