diff --git a/backend/storj/fs.go b/backend/storj/fs.go index 97c126620..da37748b5 100644 --- a/backend/storj/fs.go +++ b/backend/storj/fs.go @@ -705,7 +705,16 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object, // Do the move err := f.project.MoveObject(ctx, srcBucket, srcKey, dstBucket, dstKey, &options) if err != nil { - return nil, fmt.Errorf("rename object failed: %w", err) + // Make sure destination bucket exists + _, err := f.project.EnsureBucket(ctx, dstBucket) + if err != nil { + return nil, fmt.Errorf("rename object failed to create destination bucket: %w", err) + } + // And try again + err = f.project.MoveObject(ctx, srcBucket, srcKey, dstBucket, dstKey, &options) + if err != nil { + return nil, fmt.Errorf("rename object failed: %w", err) + } } // Read the new object