diff --git a/objstore.go b/objstore.go index f6bcac6c..d201a6bf 100644 --- a/objstore.go +++ b/objstore.go @@ -284,6 +284,7 @@ type ObjectAttributes struct { type IterObjectAttributes struct { Name string + Size int64 lastModified time.Time } diff --git a/providers/azure/azure.go b/providers/azure/azure.go index f3b891ec..91699baa 100644 --- a/providers/azure/azure.go +++ b/providers/azure/azure.go @@ -232,6 +232,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr for _, blob := range resp.Segment.BlobItems { attrs := objstore.IterObjectAttributes{ Name: *blob.Name, + Size: *blob.Properties.ContentLength, } if params.LastModified { attrs.SetLastModified(*blob.Properties.LastModified) diff --git a/providers/bos/bos.go b/providers/bos/bos.go index be7a1b3c..2c783f7f 100644 --- a/providers/bos/bos.go +++ b/providers/bos/bos.go @@ -219,6 +219,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr for _, object := range objects.Contents { attrs := objstore.IterObjectAttributes{ Name: object.Key, + Size: int64(object.Size), } if params.LastModified && object.LastModified != "" { diff --git a/providers/filesystem/filesystem.go b/providers/filesystem/filesystem.go index 3717cf3d..7d350890 100644 --- a/providers/filesystem/filesystem.go +++ b/providers/filesystem/filesystem.go @@ -109,17 +109,17 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr continue } } + finfo, err := file.Info() + if err != nil { + return errors.Wrapf(err, "stat %s", name) + } attrs := objstore.IterObjectAttributes{ Name: name, + Size: finfo.Size(), } if params.LastModified { - absPath := filepath.Join(absDir, file.Name()) - stat, err := os.Stat(absPath) - if err != nil { - return errors.Wrapf(err, "stat %s", name) - } - attrs.SetLastModified(stat.ModTime()) + attrs.SetLastModified(finfo.ModTime()) } if err := f(attrs); err != nil { return err diff --git a/providers/gcs/gcs.go b/providers/gcs/gcs.go index b8723b8c..1250e145 100644 --- a/providers/gcs/gcs.go +++ b/providers/gcs/gcs.go @@ -244,7 +244,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr return err } - objAttrs := objstore.IterObjectAttributes{Name: attrs.Prefix + attrs.Name} + objAttrs := objstore.IterObjectAttributes{Name: attrs.Prefix + attrs.Name, Size: attrs.Size} if appliedOpts.LastModified { objAttrs.SetLastModified(attrs.Updated) } diff --git a/providers/s3/s3.go b/providers/s3/s3.go index 5c8cd953..1eb4dcfb 100644 --- a/providers/s3/s3.go +++ b/providers/s3/s3.go @@ -430,6 +430,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr attr := objstore.IterObjectAttributes{ Name: object.Key, + Size: object.Size, } if appliedOpts.LastModified { attr.SetLastModified(object.LastModified)