Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ type ObjectAttributes struct {

type IterObjectAttributes struct {
Name string
Size int64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the size be negative? Maybe let's use uint64.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe as a canary for "this provider does not expose a size in iter"; idk if there is such a provider though

lastModified time.Time
}

Expand Down
1 change: 1 addition & 0 deletions providers/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SizeBytes would be preferable, I think!

}
if params.LastModified {
attrs.SetLastModified(*blob.Properties.LastModified)
Expand Down
1 change: 1 addition & 0 deletions providers/bos/bos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
12 changes: 6 additions & 6 deletions providers/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion providers/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions providers/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading