From d38e20337056b05d970b5140335953ca7b15ca8c Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 3 Sep 2021 10:49:05 +0200 Subject: Fix renaming --- s3_fs.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/s3_fs.go b/s3_fs.go index f8983ef..e93edb3 100644 --- a/s3_fs.go +++ b/s3_fs.go @@ -113,7 +113,6 @@ func (s S3FS) Rename(ctx context.Context, oldName, newName string) error { //Gather all keys, copy the object, delete the original objCh := s.mc.ListObjects(s.ctx, po.bucket, minio.ListObjectsOptions{Prefix: po.key, Recursive: true}) for obj := range objCh { - log.Println("found object", obj) src := minio.CopySrcOptions{ Bucket: po.bucket, Object: obj.Key, @@ -125,16 +124,17 @@ func (s S3FS) Rename(ctx context.Context, oldName, newName string) error { } _, err := s.mc.CopyObject(s.ctx, dst, src) - log.Println("copy", obj) if err != nil { - log.Println("copy err", err) return err } - log.Println("delete", obj) err = s.mc.RemoveObject(s.ctx, po.bucket, obj.Key, minio.RemoveObjectOptions{}) - if err != nil /*&& err.Code != 200*/ /* @FIXME workaround for garage's bug #98 */ { - log.Println("delete err", err) + var e minio.ErrorResponse + log.Println(errors.As(err, &e)) + log.Println(e) + if errors.As(err, &e) && e.StatusCode == 200 { + /* @FIXME workaround for garage's bug #98 */ + } else if err != nil { return err } } -- cgit v1.2.3