Skip to content

Commit 94d26ca

Browse files
committed
Request name for GCS
Signed-off-by: Filip Petkovski <[email protected]>
1 parent 3b23d35 commit 94d26ca

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

objstore.go

+1-10
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,7 @@ type ObjectAttributes struct {
246246

247247
type IterObjectAttributes struct {
248248
Name string
249-
lastModified time.Time
250-
}
251-
252-
func (i *IterObjectAttributes) SetLastModified(t time.Time) {
253-
i.lastModified = t
254-
}
255-
256-
// LastModified returns the timestamp the object was last modified. Returns false if the timestamp is not available.
257-
func (i *IterObjectAttributes) LastModified() (time.Time, bool) {
258-
return i.lastModified, !i.lastModified.IsZero()
249+
LastModified time.Time
259250
}
260251

261252
// TryToGetSize tries to get upfront size from reader.

providers/azure/azure.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
221221
Name: *blob.Name,
222222
}
223223
if params.LastModified {
224-
attrs.SetLastModified(*blob.Properties.LastModified)
224+
attrs.LastModified = *blob.Properties.LastModified
225225
}
226226
if err := f(attrs); err != nil {
227227
return err
@@ -243,7 +243,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
243243
Name: *blobItem.Name,
244244
}
245245
if params.LastModified {
246-
attrs.SetLastModified(*blobItem.Properties.LastModified)
246+
attrs.LastModified = *blobItem.Properties.LastModified
247247
}
248248
if err := f(attrs); err != nil {
249249
return err

providers/bos/bos.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
223223
if err != nil {
224224
return fmt.Errorf("iter: get last modified: %w", err)
225225
}
226-
attrs.SetLastModified(lastModified)
226+
attrs.LastModified = lastModified
227227
}
228228

229229
if err := f(attrs); err != nil {

providers/filesystem/filesystem.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
117117
if err != nil {
118118
return errors.Wrapf(err, "stat %s", name)
119119
}
120-
attrs.SetLastModified(stat.ModTime())
120+
attrs.LastModified = stat.ModTime()
121121
}
122122
if err := f(attrs); err != nil {
123123
return err

providers/gcs/gcs.go

+16-5
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,21 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
204204
delimiter = ""
205205
}
206206

207-
it := b.bkt.Objects(ctx, &storage.Query{
207+
query := &storage.Query{
208208
Prefix: dir,
209209
Delimiter: delimiter,
210-
})
210+
}
211+
212+
if appliedOpts.LastModified {
213+
if err := query.SetAttrSelection([]string{"Name", "Updated"}); err != nil {
214+
return err
215+
}
216+
} else {
217+
if err := query.SetAttrSelection([]string{"Name"}); err != nil {
218+
return err
219+
}
220+
}
221+
it := b.bkt.Objects(ctx, query)
211222
for {
212223
select {
213224
case <-ctx.Done():
@@ -222,9 +233,9 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
222233
return err
223234
}
224235

225-
objAttrs := objstore.IterObjectAttributes{Name: attrs.Prefix + attrs.Name}
226-
if appliedOpts.LastModified {
227-
objAttrs.SetLastModified(attrs.Updated)
236+
objAttrs := objstore.IterObjectAttributes{
237+
Name: attrs.Prefix + attrs.Name,
238+
LastModified: attrs.Updated,
228239
}
229240
if err := f(objAttrs); err != nil {
230241
return err

providers/s3/s3.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ func (b *Bucket) IterWithAttributes(ctx context.Context, dir string, f func(attr
428428
Name: object.Key,
429429
}
430430
if appliedOpts.LastModified {
431-
attr.SetLastModified(object.LastModified)
431+
attr.LastModified = object.LastModified
432432
}
433433

434434
if err := f(attr); err != nil {

0 commit comments

Comments
 (0)