upip: Don't rely on presence of directory entries in tar.

Just create intermediate path components for every filename.
pull/106/head
Paul Sokolovsky 2016-10-08 14:41:41 +03:00
rodzic 69390da38f
commit 29c90a6231
1 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -31,10 +31,11 @@ def op_split(path):
def op_basename(path): def op_basename(path):
return op_split(path)[1] return op_split(path)[1]
# Expects *file* name
def _makedirs(name, mode=0o777): def _makedirs(name, mode=0o777):
ret = False ret = False
s = "" s = ""
for c in name.rstrip("/").split("/"): for c in name.rstrip("/").split("/")[:-1]:
if s: if s:
s += "/" s += "/"
s += c s += c
@ -80,12 +81,10 @@ def install_tar(f, prefix):
if save: if save:
outfname = prefix + fname outfname = prefix + fname
if info.type == tarfile.DIRTYPE: if info.type != tarfile.DIRTYPE:
if _makedirs(outfname):
print("Created " + outfname)
else:
if debug: if debug:
print("Extracting " + outfname) print("Extracting " + outfname)
_makedirs(outfname)
subf = f.extractfile(info) subf = f.extractfile(info)
save_file(outfname, subf) save_file(outfname, subf)
return meta return meta