MCPcopy Create free account
hub / github.com/dropbox/dbxcli / putRecursiveInternal

Function putRecursiveInternal

cmd/put.go:734–848  ·  view source on GitHub ↗
(src, dst string, opts putOptions, collectResults bool)

Source from the content-addressed store, hash-verified

732}
733
734func putRecursiveInternal(src, dst string, opts putOptions, collectResults bool) ([]putResult, []jsonWarning, error) {
735 src = filepath.Clean(src)
736 var results []putResult
737 var warnings []jsonWarning
738 var uploadErrors []error
739 dirsWithFiles := make(map[string]bool)
740
741 err := filepath.WalkDir(src, func(filePath string, d os.DirEntry, err error) error {
742 if err != nil {
743 return err
744 }
745 if d.IsDir() {
746 return nil
747 }
748 if !d.Type().IsRegular() {
749 if collectResults && d.Type()&os.ModeSymlink != 0 {
750 warnings = append(warnings, jsonWarning{
751 Code: jsonWarningCodeSkippedSymlink,
752 Message: "skipped symlink during recursive upload",
753 Path: filePath,
754 })
755 }
756 return nil
757 }
758
759 relPath, err := filepath.Rel(src, filePath)
760 if err != nil {
761 return err
762 }
763
764 dirsWithFiles[filepath.Dir(filePath)] = true
765
766 remotePath := path.Join(dst, filepath.ToSlash(relPath))
767 putOutput(opts).Status("Processing %s -> %s", filePath, remotePath)
768
769 if collectResults {
770 result, err := putFileWithResult(filePath, remotePath, opts)
771 if err != nil {
772 uploadErrors = append(uploadErrors, fmt.Errorf("%s: %w", filePath, err))
773 return nil
774 }
775 results = append(results, result)
776 return nil
777 }
778 if err := putFile(filePath, remotePath, opts); err != nil {
779 uploadErrors = append(uploadErrors, fmt.Errorf("%s: %w", filePath, err))
780 return nil
781 }
782 return nil
783 })
784 if err != nil {
785 return nil, nil, withJSONErrorDetails(err, operationErrorDetails("upload"), pathErrorDetails(src))
786 }
787
788 dbx := filesNewFunc(config)
789
790 putOutput(opts).Status("Creating directory %s", dst)
791 if collectResults {

Callers 2

putRecursiveFunction · 0.85
putRecursiveWithResultsFunction · 0.85

Calls 12

putOutputFunction · 0.85
putFileWithResultFunction · 0.85
putFileFunction · 0.85
withJSONErrorDetailsFunction · 0.85
operationErrorDetailsFunction · 0.85
pathErrorDetailsFunction · 0.85
putDirectoryWithResultFunction · 0.85
putDirectoryFunction · 0.85
mergeJSONErrorDetailsFunction · 0.85
relocationErrorDetailsFunction · 0.85
StatusMethod · 0.80

Tested by

no test coverage detected