Skip to content

Commit 4c59740

Browse files
author
Ahmed Bilal
committed
[IO] Fix rootcp --replace flag not working with recursive copy
The --replace flag was not being checked when copying regular objects (non-tree, non-collection) in recursive mode. This caused objects to be written with new cycles instead of replacing existing ones. Added replaceOption check in the else block of copyRootObjectRecursive() to delete existing objects before writing replacements. Fixes #7052
1 parent 7b3872e commit 4c59740

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

main/python/cmdLineUtils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ def copyRootObjectRecursive(sourceFile, sourcePathSplit, destFile, destPathSplit
709709
changeDirectory(destFile, destPathSplit)
710710
obj.Write(setName, ROOT.TObject.kSingleKey)
711711
else:
712+
if replaceOption and isExisting(destFile, destPathSplit + [objectName]):
713+
retcodeTemp = deleteObject(destFile, destPathSplit + [objectName])
714+
if retcodeTemp:
715+
retcode += retcodeTemp
716+
obj.Delete()
717+
continue
712718
if setName != "":
713719
if isinstance(obj, ROOT.TNamed):
714720
obj.SetName(setName)

0 commit comments

Comments
 (0)