backup upload archives: avoid gzip compressing the files 21/31021/1
authorAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 29 Jan 2021 11:31:43 +0000 (11:31 +0000)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 29 Jan 2021 11:31:43 +0000 (11:31 +0000)
if they are already compressed

Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Change-Id: Ie0ce0a303f3d681b8aae697c1b358534e68b2c28

jjb/scripts/backup_upload_archives.sh

index a7eb166..1a9c577 100755 (executable)
@@ -77,11 +77,13 @@ def upload(storage, bucket, src_fpath, dst_fpath):
     :type src_fpath: str
     :type dst_fpath: str
     """
-    mime = MimeTypes().guess_type(src_fpath)[0]
+    mime_guess = MimeTypes().guess_type(src_fpath)
+    mime = mime_guess[0]
+    encoding = mime_guess[1]
     if not mime:
         mime = "application/octet-stream"
 
-    if mime in COMPRESS_MIME and bucket in "logs":
+    if mime in COMPRESS_MIME and bucket in "logs" and encoding != "gzip":
         compress(src_fpath)
         src_fpath = src_fpath + ".gz"
         dst_fpath = dst_fpath + ".gz"