Struct: s3manager.BatchDelete

import "../ibm-cos-sdk-go/service/s3/s3manager"

Overview

BatchDelete will use the s3 package's service client to perform a batch delete.

Implemented Interfaces

s3manageriface.BatchDelete, s3crypto.Cipher, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Structure Field Summary collapse

Method Summary collapse

Structure Field Details

BatchSize int

Client s3iface.S3API

Method Details

func (d *BatchDelete) Delete(ctx aws.Context, iter BatchDeleteIterator) error

Delete will use the iterator to queue up objects that need to be deleted. Once the batch size is met, this will call the deleteBatch function.



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
// File 'service/s3/s3manager/batch.go', line 303

func (d *BatchDelete) Delete(ctx aws.Context, iter BatchDeleteIterator) error { var errs []Error objects := []BatchDeleteObject{} var input *s3.DeleteObjectsInput for iter.Next() { o := iter.DeleteObject() if input == nil { input = initDeleteObjectsInput(o.Object) } parity := hasParity(input, o) if parity { input.Delete.Objects = append(input.Delete.Objects, &s3.ObjectIdentifier{ Key: o.Object.Key, VersionId: o.Object.VersionId, }) objects = append(objects, o) } if len(input.Delete.Objects) == d.BatchSize || !parity { if err := deleteBatch(ctx, d, input, objects); err != nil { errs = append(errs, err...) } objects = objects[:0] input = nil if !parity { objects = append(objects, o) input = initDeleteObjectsInput(o.Object) input.Delete.Objects = append(input.Delete.Objects, &s3.ObjectIdentifier{ Key: o.Object.Key, VersionId: o.Object.VersionId, }) } } } // iter.Next() could return false (above) plus populate iter.Err() if iter.Err() != nil { errs = append(errs, newError(iter.Err(), nil, nil)) } if input != nil && len(input.Delete.Objects) > 0 { if err := deleteBatch(ctx, d, input, objects); err != nil { errs = append(errs, err...) } } if len(errs) > 0 { return NewBatchError("BatchedDeleteIncomplete", "some objects have failed to be deleted.", errs) } return nil }