Merge pull request #2 from bitwave/tar-lzma-support

added compression method lzma for tar files
This commit is contained in:
Sebastian Lohff 2019-02-14 23:22:58 +01:00 committed by GitHub
commit 53d803626d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -227,7 +227,7 @@ class FileHandler(FileBaseHandler):
class TarFileHandler(FileBaseHandler): class TarFileHandler(FileBaseHandler):
target = None target = None
compression = "none" compression = "none"
compressionMethods = ("none", "gzip", "bzip2") compressionMethods = ("none", "gzip", "bzip2", "xz")
def do_HEAD(self): def do_HEAD(self):
if self.checkAndDoRedirect(): if self.checkAndDoRedirect():
@ -269,6 +269,8 @@ class TarFileHandler(FileBaseHandler):
cmd = ["tar", "-cz"] cmd = ["tar", "-cz"]
elif self.compression == "bzip2": elif self.compression == "bzip2":
cmd = ["tar", "-cj"] cmd = ["tar", "-cj"]
elif self.compression == "xz":
cmd = ["tar", "-cJ"]
else: else:
raise ValueError("Unknown compression mode '%s'." % self.compression) raise ValueError("Unknown compression mode '%s'." % self.compression)
@ -287,6 +289,8 @@ class TarFileHandler(FileBaseHandler):
return ".tar.gz" return ".tar.gz"
elif TarFileHandler.compression == "bzip2": elif TarFileHandler.compression == "bzip2":
return ".tar.bz2" return ".tar.bz2"
elif TarFileHandler.compression == "xz":
return ".tar.xz"
raise ValueError("Unknown compression mode '%s'." % TarFileHandler.compression) raise ValueError("Unknown compression mode '%s'." % TarFileHandler.compression)