Browse Source

Fix renaming

main
Quentin 9 months ago
parent
commit
d38e203370
Signed by untrusted user: quentin GPG Key ID: A98E9B769E4FF428
  1. 12
      s3_fs.go

12
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
}
}

Loading…
Cancel
Save