List will list all the objects in this store.
(ctx context.Context, opts ...ListObjectsOpt)
| 1350 | |
| 1351 | // List will list all the objects in this store. |
| 1352 | func (obs *obs) List(ctx context.Context, opts ...ListObjectsOpt) ([]*ObjectInfo, error) { |
| 1353 | var o listObjectOpts |
| 1354 | for _, opt := range opts { |
| 1355 | if opt != nil { |
| 1356 | if err := opt(&o); err != nil { |
| 1357 | return nil, err |
| 1358 | } |
| 1359 | } |
| 1360 | } |
| 1361 | watchOpts := make([]WatchOpt, 0) |
| 1362 | if !o.showDeleted { |
| 1363 | watchOpts = append(watchOpts, IgnoreDeletes()) |
| 1364 | } |
| 1365 | watcher, err := obs.Watch(ctx, watchOpts...) |
| 1366 | if err != nil { |
| 1367 | return nil, err |
| 1368 | } |
| 1369 | defer watcher.Stop() |
| 1370 | |
| 1371 | var objs []*ObjectInfo |
| 1372 | updates := watcher.Updates() |
| 1373 | Updates: |
| 1374 | for { |
| 1375 | select { |
| 1376 | case entry := <-updates: |
| 1377 | if entry == nil { |
| 1378 | break Updates |
| 1379 | } |
| 1380 | objs = append(objs, entry) |
| 1381 | case <-ctx.Done(): |
| 1382 | return nil, ctx.Err() |
| 1383 | } |
| 1384 | } |
| 1385 | if len(objs) == 0 { |
| 1386 | return nil, ErrNoObjectsFound |
| 1387 | } |
| 1388 | return objs, nil |
| 1389 | } |
| 1390 | |
| 1391 | // ObjectBucketStatus represents status of a Bucket, implements ObjectStoreStatus |
| 1392 | type ObjectBucketStatus struct { |