Skip to content

Commit

Permalink
mark path map for all parent dirs too
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Feb 15, 2024
1 parent 9bfc042 commit eb90681
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
6 changes: 2 additions & 4 deletions cmd/subcmd/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,10 @@ func copyOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[st
return xerrors.Errorf("failed to stat %s: %w", sourcePath, err)
}

inputPathMap[targetPath] = true

if sourceEntry.Type == irodsclient_fs.FileEntry {
// file
targetFilePath := commons.MakeTargetIRODSFilePath(filesystem, sourcePath, targetPath)
inputPathMap[targetFilePath] = true
commons.MarkPathMap(inputPathMap, targetFilePath)

fileExist := false
targetEntry, err := filesystem.StatFile(targetFilePath)
Expand Down Expand Up @@ -234,7 +232,7 @@ func copyOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[st
}
}

inputPathMap[targetDirPath] = true
commons.MarkPathMap(inputPathMap, targetDirPath)

err = copyOne(parallelJobManager, inputPathMap, entry.Path, targetDirPath, recurse, force, diff, noHash)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions cmd/subcmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,10 @@ func getOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[str
return xerrors.Errorf("failed to stat %s: %w", sourcePath, err)
}

inputPathMap[targetPath] = true

if sourceEntry.Type == irodsclient_fs.FileEntry {
// file
targetFilePath := commons.MakeTargetLocalFilePath(sourcePath, targetPath)
inputPathMap[targetFilePath] = true
commons.MarkPathMap(inputPathMap, targetFilePath)

fileExist := false
targetEntry, err := os.Stat(targetFilePath)
Expand Down Expand Up @@ -290,7 +288,7 @@ func getOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[str
}
}

inputPathMap[targetDirPath] = true
commons.MarkPathMap(inputPathMap, targetDirPath)

err = getOne(parallelJobManager, inputPathMap, entry.Path, targetDirPath, force, diff, noHash)
if err != nil {
Expand Down
13 changes: 2 additions & 11 deletions cmd/subcmd/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,6 @@ func processPutCommand(command *cobra.Command, args []string) error {
return nil
}

func markInputPathMap(inputPathMap map[string]bool, p string) {
dirs := commons.GetParentIRODSDirs(p)
for _, dir := range dirs {
inputPathMap[dir] = true
}

inputPathMap[p] = true
}

func putOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[string]bool, sourcePath string, targetPath string, force bool, singleThreaded bool, diff bool, noHash bool) error {
logger := log.WithFields(log.Fields{
"package": "main",
Expand All @@ -188,7 +179,7 @@ func putOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[str
if !sourceStat.IsDir() {
// file
targetFilePath := commons.MakeTargetIRODSFilePath(filesystem, sourcePath, targetPath)
markInputPathMap(inputPathMap, targetFilePath)
commons.MarkPathMap(inputPathMap, targetFilePath)

fileExist := false
targetEntry, err := filesystem.StatFile(targetFilePath)
Expand Down Expand Up @@ -284,7 +275,7 @@ func putOne(parallelJobManager *commons.ParallelJobManager, inputPathMap map[str
}
}

markInputPathMap(inputPathMap, targetDirPath)
commons.MarkPathMap(inputPathMap, targetDirPath)

newSourcePath := filepath.Join(sourcePath, entry.Name())
err = putOne(parallelJobManager, inputPathMap, newSourcePath, targetDirPath, force, singleThreaded, diff, noHash)
Expand Down
2 changes: 1 addition & 1 deletion commons/bundle_transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (manager *BundleTransferManager) Schedule(source string, dir bool, size int
return xerrors.Errorf("failed to get target path for %s: %w", source, err)
}

manager.inputPathMap[targePath] = true
MarkPathMap(manager.inputPathMap, targePath)

if manager.differentFilesOnly {
logger.Debugf("checking if target %s for source %s exists", targePath, source)
Expand Down
9 changes: 9 additions & 0 deletions commons/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,12 @@ func ExistFile(p string) bool {
}
return false
}

func MarkPathMap(pathMap map[string]bool, p string) {
dirs := GetParentIRODSDirs(p)
for _, dir := range dirs {
pathMap[dir] = true
}

pathMap[p] = true
}

0 comments on commit eb90681

Please sign in to comment.