MCPcopy
hub / github.com/wavetermdev/waveterm / fileCpRun

Function fileCpRun

cmd/wsh/cmd/wshcmd-file.go:347–379  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

345}
346
347func fileCpRun(cmd *cobra.Command, args []string) error {
348 src, dst := args[0], args[1]
349 merge, err := cmd.Flags().GetBool("merge")
350 if err != nil {
351 return err
352 }
353 force, err := cmd.Flags().GetBool("force")
354 if err != nil {
355 return err
356 }
357
358 srcPath, err := fixRelativePaths(src)
359 if err != nil {
360 return fmt.Errorf("unable to parse src path: %w", err)
361 }
362
363 _, err = checkFileSize(srcPath, MaxFileSize)
364 if err != nil {
365 return err
366 }
367
368 destPath, err := fixRelativePaths(dst)
369 if err != nil {
370 return fmt.Errorf("unable to parse dest path: %w", err)
371 }
372 log.Printf("Copying %s to %s; merge: %v, force: %v", srcPath, destPath, merge, force)
373 rpcOpts := &wshrpc.RpcOpts{Timeout: TimeoutYear}
374 err = wshclient.FileCopyCommand(RpcClient, wshrpc.CommandFileCopyData{SrcUri: srcPath, DestUri: destPath, Opts: &wshrpc.FileCopyOpts{Merge: merge, Overwrite: force, Timeout: TimeoutYear}}, rpcOpts)
375 if err != nil {
376 return fmt.Errorf("copying file: %w", err)
377 }
378 return nil
379}
380
381func fileMvRun(cmd *cobra.Command, args []string) error {
382 src, dst := args[0], args[1]

Callers

nothing calls this directly

Calls 4

FileCopyCommandFunction · 0.92
fixRelativePathsFunction · 0.85
GetBoolMethod · 0.80
checkFileSizeFunction · 0.70

Tested by

no test coverage detected