forked from Mirrors/btrfs-progs
Btrfs-progs: Correct path munging in bcp
Bcp was assuming that a path on the command line would never have a slash after it, which is silly, and would cause the first letter of everything in the root of the source to be truncated. Instead, use os.path.relpath to handle it properly. Signed-off-by: Carey Underwood <cwillu@cwillu.com> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>master
parent
48d29930ed
commit
796a0e9cc4
6
bcp
6
bcp
|
@ -136,8 +136,7 @@ for srci in xrange(0, src_args):
|
||||||
srcname = os.path.join(dirpath, x)
|
srcname = os.path.join(dirpath, x)
|
||||||
statinfo = os.lstat(srcname)
|
statinfo = os.lstat(srcname)
|
||||||
|
|
||||||
if srcname.startswith(src):
|
part = os.path.relpath(srcname, src)
|
||||||
part = srcname[len(src) + 1:]
|
|
||||||
|
|
||||||
if stat.S_ISLNK(statinfo.st_mode):
|
if stat.S_ISLNK(statinfo.st_mode):
|
||||||
copylink(srcname, dst, part, statinfo, None)
|
copylink(srcname, dst, part, statinfo, None)
|
||||||
|
@ -152,8 +151,7 @@ for srci in xrange(0, src_args):
|
||||||
|
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
srcname = os.path.join(dirpath, f)
|
srcname = os.path.join(dirpath, f)
|
||||||
if srcname.startswith(src):
|
part = os.path.relpath(srcname, src)
|
||||||
part = srcname[len(src) + 1:]
|
|
||||||
|
|
||||||
statinfo = os.lstat(srcname)
|
statinfo = os.lstat(srcname)
|
||||||
copyfile(srcname, dst, part, statinfo, None)
|
copyfile(srcname, dst, part, statinfo, None)
|
||||||
|
|
Loading…
Reference in New Issue