forked from mtusi2026/mtusi2026lab6
27 lines
798 B
Go
27 lines
798 B
Go
package objectstore
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/minio/minio-go/v7"
|
|
|
|
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/media"
|
|
)
|
|
|
|
// List bounds each reconciliation page and cancels the SDK producer before returning.
|
|
func (c *Client) List(ctx context.Context, after string) ([]media.ObjectInfo, error) {
|
|
ctx, cancel := context.WithTimeout(ctx, operationTimeout)
|
|
defer cancel()
|
|
result := make([]media.ObjectInfo, 0, 1000)
|
|
for object := range c.client.ListObjects(ctx, c.bucket, minio.ListObjectsOptions{Prefix: "", StartAfter: after, Recursive: true, MaxKeys: 1000}) {
|
|
if object.Err != nil {
|
|
return nil, object.Err
|
|
}
|
|
result = append(result, media.ObjectInfo{Key: object.Key, ModifiedAt: object.LastModified})
|
|
if len(result) == 1000 {
|
|
break
|
|
}
|
|
}
|
|
return result, nil
|
|
}
|