Fix renaming

This commit is contained in:
Quentin 2021-09-03 10:49:05 +02:00
parent e83c3a13b2
commit d38e203370
Signed by: quentin
GPG key ID: A98E9B769E4FF428

View file

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