cppo detects invalid SHK rather than creating empty folder

This commit is contained in:
Ivan X
2016-01-06 06:12:24 -05:00
parent 502e638964
commit 71274cb18f
+11 -5
View File
@@ -1169,15 +1169,21 @@ if g.SHK:
targetDir = (args[3] if g.extractFile else args[2])
unshkdir = ("/tmp/cppo-" + str(uuid.uuid4()))
makedirs(unshkdir)
if not os.system("cd " + unshkdir + "; " +
"nulib2 -xse " +
os.path.abspath(g.imageFile) + " " +
(args[2].replace('/', ':') if g.extractFile else "") +
" | grep -q 'no records match' > /dev/null"):
result = os.system("/bin/bash -c 'cd " + unshkdir + "; " +
"result=$(nulib2 -xse " + os.path.abspath(g.imageFile) +
((" " + args[2].replace('/', ':'))
if g.extractFile else "") + " 2> /dev/null); " +
"if [[ $result == \"Failed.\" ]]; then exit 3; " +
"else if grep -q \"no records match\" <<< \"$result\"" +
" > /dev/null; then exit 2; else exit 0; fi; fi'")
if (result == 512):
print(
"File not found in ShrinkIt archive. Try cppo -cat to get the path,")
print(" and omit any leading slash or colon.")
sys.exit(1)
elif (result != 0):
print("ShrinkIt archive is invalid, or some other problem happened.")
sys.exit(1)
if g.extractFile:
g.extractFile = g.extractFile.replace(':', '/')
extractPath = (unshkdir + "/" + g.extractFile)