Skip to content

Commit

Permalink
HPCC-32639 Prevent ECLWatch file rename from mangling path
Browse files Browse the repository at this point in the history
Ensure a path separator is added between two components of the new path as
it is used to update metadata and rename a file.

Signed-off-by: Terrence Asselin <[email protected]>
  • Loading branch information
asselitx committed Oct 15, 2024
1 parent ffc03a3 commit 9293ae5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ inline unsigned groupDistance(IGroup *grp1,IGroup *grp2)
return grp1->distance(grp2);
}

inline StringBuffer &appendEnsurePathSepChar(StringBuffer &dest, StringBuffer &newPart, char psc)
{
addPathSepChar(dest, psc);
if (newPart.length() > 0)
{
if (isPathSepChar(newPart.charAt(0)))
dest.append(newPart.str()+1);
else
dest.append(newPart);
}
return dest;
}


static StringBuffer &normalizeFormat(StringBuffer &in)
{
Expand Down Expand Up @@ -4474,7 +4487,8 @@ protected: friend class CDistributedFilePart;
if (isPathSepChar(newPath.charAt(newPath.length()-1)))
newPath.setLength(newPath.length()-1);
newPath.remove(0, myBase.length());
newdir.append(baseDir).append(newPath);
newdir.append(baseDir);
appendEnsurePathSepChar(newdir, newPath, psc);
StringBuffer fullname;
CIArrayOf<CIStringArray> newNames;
unsigned i;
Expand All @@ -4493,7 +4507,8 @@ protected: friend class CDistributedFilePart;

StringBuffer copyDir(baseDir);
adjustClusterDir(i, copy, copyDir);
fullname.clear().append(copyDir).append(newPath);
fullname.clear().append(copyDir);
appendEnsurePathSepChar(fullname, newPath, psc);
newNames.item(i).append(fullname);
}
}
Expand Down

0 comments on commit 9293ae5

Please sign in to comment.