Merge pull request #154 from sgotti/objectstorage_object_size
objectstorage: return object size in objectinfo
This commit is contained in:
commit
2e520dae55
|
@ -73,7 +73,7 @@ func (s *PosixStorage) Stat(p string) (*types.ObjectInfo, error) {
|
||||||
return nil, err
|
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) {
|
func (s *PosixStorage) ReadObject(p string) (types.ReadSeekCloser, error) {
|
||||||
|
@ -219,7 +219,7 @@ func (s *PosixStorage) List(prefix, startWith, delimiter string, doneCh <-chan s
|
||||||
if strings.HasPrefix(p, prefix) && p > startWith {
|
if strings.HasPrefix(p, prefix) && p > startWith {
|
||||||
select {
|
select {
|
||||||
// Send object content.
|
// 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.
|
// If receives done from the caller, return here.
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
return io.EOF
|
return io.EOF
|
||||||
|
|
|
@ -249,7 +249,7 @@ func (s *PosixFlatStorage) Stat(p string) (*types.ObjectInfo, error) {
|
||||||
return nil, err
|
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) {
|
func (s *PosixFlatStorage) ReadObject(p string) (types.ReadSeekCloser, error) {
|
||||||
|
@ -416,7 +416,7 @@ func (s *PosixFlatStorage) List(prefix, startWith, delimiter string, doneCh <-ch
|
||||||
if p > prevp {
|
if p > prevp {
|
||||||
select {
|
select {
|
||||||
// Send object content.
|
// 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.
|
// If receives done from the caller, return here.
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
return io.EOF
|
return io.EOF
|
||||||
|
|
|
@ -72,7 +72,7 @@ func (s *S3Storage) Stat(p string) (*types.ObjectInfo, error) {
|
||||||
return nil, merr
|
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) {
|
func (s *S3Storage) ReadObject(filepath string) (types.ReadSeekCloser, error) {
|
||||||
|
@ -157,7 +157,7 @@ func (s *S3Storage) List(prefix, startWith, delimiter string, doneCh <-chan stru
|
||||||
for _, object := range result.Contents {
|
for _, object := range result.Contents {
|
||||||
select {
|
select {
|
||||||
// Send object content.
|
// 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.
|
// If receives done from the caller, return here.
|
||||||
case <-doneCh:
|
case <-doneCh:
|
||||||
return
|
return
|
||||||
|
|
|
@ -34,8 +34,8 @@ type ReadSeekCloser interface {
|
||||||
|
|
||||||
type ObjectInfo struct {
|
type ObjectInfo struct {
|
||||||
Path string
|
Path string
|
||||||
|
|
||||||
LastModified time.Time
|
LastModified time.Time
|
||||||
|
Size int64
|
||||||
|
|
||||||
Err error
|
Err error
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue