list the objects into the function supplied from the bucket and root supplied (bucket, directory) is the starting directory If prefix is set then it is removed from all file names If addBucket is set then it adds the bucket to the start of the remotes generated If recurse is set the function will re
(ctx context.Context, bucket, directory, prefix string, addBucket bool, recurse bool, limit int, fn listFn)
| 310 | // If hidden is set then it will list the hidden (deleted) files too. |
| 311 | // if findFile is set it will look for files called (bucket, directory) |
| 312 | func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBucket bool, recurse bool, limit int, |
| 313 | fn listFn) (err error) { |
| 314 | if prefix != "" { |
| 315 | prefix += "/" |
| 316 | } |
| 317 | if directory != "" { |
| 318 | directory += "/" |
| 319 | } |
| 320 | |
| 321 | delimiter := "" |
| 322 | if !recurse { |
| 323 | delimiter = "/" |
| 324 | } |
| 325 | chunkSize := 1000 |
| 326 | if limit > 0 { |
| 327 | chunkSize = limit |
| 328 | } |
| 329 | var request = objectstorage.ListObjectsRequest{ |
| 330 | NamespaceName: common.String(f.opt.Namespace), |
| 331 | BucketName: common.String(bucket), |
| 332 | Prefix: common.String(directory), |
| 333 | Limit: common.Int(chunkSize), |
| 334 | Fields: common.String("name,size,etag,timeCreated,md5,timeModified,storageTier,archivalState"), |
| 335 | } |
| 336 | if delimiter != "" { |
| 337 | request.Delimiter = common.String(delimiter) |
| 338 | } |
| 339 | |
| 340 | for { |
| 341 | var resp objectstorage.ListObjectsResponse |
| 342 | err = f.pacer.Call(func() (bool, error) { |
| 343 | var err error |
| 344 | resp, err = f.srv.ListObjects(ctx, request) |
| 345 | return shouldRetry(ctx, resp.HTTPResponse(), err) |
| 346 | }) |
| 347 | if err != nil { |
| 348 | if ociError, ok := err.(common.ServiceError); ok { |
| 349 | // If it is a timeout then we want to retry that |
| 350 | if ociError.GetHTTPStatusCode() == http.StatusNotFound { |
| 351 | err = fs.ErrorDirNotFound |
| 352 | } |
| 353 | } |
| 354 | if f.rootBucket == "" { |
| 355 | // if listing from the root ignore wrong region requests returning |
| 356 | // empty directory |
| 357 | if reqErr, ok := err.(common.ServiceError); ok { |
| 358 | // 301 if wrong region for bucket |
| 359 | if reqErr.GetHTTPStatusCode() == http.StatusMovedPermanently { |
| 360 | fs.Errorf(f, "Can't change region for bucket %q with no bucket specified", bucket) |
| 361 | return nil |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | return err |
| 366 | } |
| 367 | if !recurse { |
| 368 | for _, commonPrefix := range resp.ListObjects.Prefixes { |
| 369 | if commonPrefix == "" { |
no test coverage detected