MCPcopy
hub / github.com/rclone/rclone / Copy

Method Copy

backend/filescom/filescom.go:505–551  ·  view source on GitHub ↗

Copy src to this remote using server-side copy operations. This is stored with the remote path given. It returns the destination Object and a possible error. Will only be called if src.Fs().Name() == f.Name() If it isn't possible then return fs.ErrorCantCopy

(ctx context.Context, src fs.Object, remote string)

Source from the content-addressed store, hash-verified

503//
504// If it isn't possible then return fs.ErrorCantCopy
505func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dstObj fs.Object, err error) {
506 srcObj, ok := src.(*Object)
507 if !ok {
508 fs.Debugf(src, "Can't copy - not same remote type")
509 return nil, fs.ErrorCantCopy
510 }
511 err = srcObj.readMetaData(ctx)
512 if err != nil {
513 return
514 }
515
516 srcPath := srcObj.fs.absPath(srcObj.remote)
517 dstPath := f.absPath(remote)
518 if strings.EqualFold(srcPath, dstPath) {
519 return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
520 }
521
522 // Create temporary object
523 dstObj, err = f.createObject(ctx, remote)
524 if err != nil {
525 return
526 }
527
528 // Copy the object
529 params := files_sdk.FileCopyParams{
530 Path: srcPath,
531 Destination: dstPath,
532 Overwrite: ptr(true),
533 }
534
535 var action files_sdk.FileAction
536 err = f.pacer.Call(func() (bool, error) {
537 action, err = f.fileClient.Copy(params, files_sdk.WithContext(ctx))
538 return shouldRetry(ctx, err)
539 })
540 if err != nil {
541 return
542 }
543
544 err = f.waitForAction(ctx, action, "copy")
545 if err != nil {
546 return
547 }
548
549 err = dstObj.SetModTime(ctx, srcObj.modTime)
550 return
551}
552
553// Purge deletes all the files and the container
554//

Callers

nothing calls this directly

Calls 11

absPathMethod · 0.95
createObjectMethod · 0.95
waitForActionMethod · 0.95
DebugfFunction · 0.92
ptrFunction · 0.70
shouldRetryFunction · 0.70
CopyMethod · 0.65
SetModTimeMethod · 0.65
readMetaDataMethod · 0.45
ErrorfMethod · 0.45
CallMethod · 0.45

Tested by

no test coverage detected