Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objectstorage: return object size in objectinfo #154

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/objectstorage/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (s *PosixStorage) Stat(p string) (*types.ObjectInfo, error) {
return nil, err
}

return &types.ObjectInfo{Path: p, LastModified: fi.ModTime()}, nil
return &types.ObjectInfo{Path: p, LastModified: fi.ModTime(), Size: fi.Size()}, nil
}

func (s *PosixStorage) ReadObject(p string) (types.ReadSeekCloser, error) {
Expand Down Expand Up @@ -215,7 +215,7 @@ func (s *PosixStorage) List(prefix, startWith, delimiter string, doneCh <-chan s
if strings.HasPrefix(p, prefix) && p > startWith {
select {
// Send object content.
case objectCh <- types.ObjectInfo{Path: p, LastModified: info.ModTime()}:
case objectCh <- types.ObjectInfo{Path: p, LastModified: info.ModTime(), Size: info.Size()}:
// If receives done from the caller, return here.
case <-doneCh:
return io.EOF
Expand Down
4 changes: 2 additions & 2 deletions internal/objectstorage/posixflat/posixflat.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ func (s *PosixFlatStorage) Stat(p string) (*types.ObjectInfo, error) {
return nil, err
}

return &types.ObjectInfo{Path: p, LastModified: fi.ModTime()}, nil
return &types.ObjectInfo{Path: p, LastModified: fi.ModTime(), Size: fi.Size()}, nil
}

func (s *PosixFlatStorage) ReadObject(p string) (types.ReadSeekCloser, error) {
Expand Down Expand Up @@ -412,7 +412,7 @@ func (s *PosixFlatStorage) List(prefix, startWith, delimiter string, doneCh <-ch
if p > prevp {
select {
// Send object content.
case objectCh <- types.ObjectInfo{Path: p, LastModified: info.ModTime()}:
case objectCh <- types.ObjectInfo{Path: p, LastModified: info.ModTime(), Size: info.Size()}:
// If receives done from the caller, return here.
case <-doneCh:
return io.EOF
Expand Down
4 changes: 2 additions & 2 deletions internal/objectstorage/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *S3Storage) Stat(p string) (*types.ObjectInfo, error) {
return nil, merr
}

return &types.ObjectInfo{Path: p, LastModified: oi.LastModified}, nil
return &types.ObjectInfo{Path: p, LastModified: oi.LastModified, Size: oi.Size}, nil
}

func (s *S3Storage) ReadObject(filepath string) (types.ReadSeekCloser, error) {
Expand Down Expand Up @@ -156,7 +156,7 @@ func (s *S3Storage) List(prefix, startWith, delimiter string, doneCh <-chan stru
for _, object := range result.Contents {
select {
// Send object content.
case objectCh <- types.ObjectInfo{Path: object.Key, LastModified: object.LastModified}:
case objectCh <- types.ObjectInfo{Path: object.Key, LastModified: object.LastModified, Size: object.Size}:
// If receives done from the caller, return here.
case <-doneCh:
return
Expand Down
4 changes: 2 additions & 2 deletions internal/objectstorage/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ type ReadSeekCloser interface {
}

type ObjectInfo struct {
Path string

Path string
LastModified time.Time
Size int64

Err error
}