Added support for compressed archives.
This commit is contained in:
parent
a66620bcc7
commit
eb18d051dc
21
crx-extract
21
crx-extract
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import glob
|
||||||
import getopt
|
import getopt
|
||||||
import tarfile
|
import tarfile
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -100,14 +101,26 @@ def main(argv):
|
||||||
|
|
||||||
if not useetag:
|
if not useetag:
|
||||||
etag = None
|
etag = None
|
||||||
tar = os.path.join(basedir, "data",
|
basetar = os.path.join(basedir, "data",
|
||||||
get_local_archive_dir(extid), extid + ".tar")
|
get_local_archive_dir(extid), extid)
|
||||||
|
tar = basetar+".tar"
|
||||||
|
|
||||||
if last != "":
|
if last != "":
|
||||||
if os.path.exists(tar):
|
if os.path.exists(tar):
|
||||||
|
files = None
|
||||||
if verbose:
|
if verbose:
|
||||||
print("Extracting " + os.path.join(output, last))
|
print("Extracting " + os.path.join(output, last) + " from " + tar)
|
||||||
with tarfile.open(tar, 'r') as archive:
|
with tarfile.open(tar, 'r') as archive:
|
||||||
archive.extractall(
|
files = archive.extractall(
|
||||||
|
path=output,
|
||||||
|
members=get_tarinfo(archive, last, winfs, etag))
|
||||||
|
archivetars = sorted(glob.glob(basetar+".[0-9][0-9][0-9].tar.xz"))
|
||||||
|
while (not files and archivetars):
|
||||||
|
tar = archivetars.pop()
|
||||||
|
if verbose:
|
||||||
|
print("Extracting " + os.path.join(output, last) + " from " + tar)
|
||||||
|
with tarfile.open(tar, 'r:xz') as archive:
|
||||||
|
files = archive.extractall(
|
||||||
path=output,
|
path=output,
|
||||||
members=get_tarinfo(archive, last, winfs, etag))
|
members=get_tarinfo(archive, last, winfs, etag))
|
||||||
elif verbose:
|
elif verbose:
|
||||||
|
|
Loading…
Reference in New Issue