]> git.ekhem.eu.org Git - gdrive_knife.git/commitdiff
Add a flag to disable unarchiving after download.
authorJakub Czajka <jakub@ekhem.eu.org>
Wed, 15 Nov 2023 22:35:21 +0000 (23:35 +0100)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 19 Nov 2023 13:59:20 +0000 (14:59 +0100)
gdrive_knife.py

index 312805f0838873ec22b87439c74f674d3df686e8..af0bda7006d81b5afaead597c4dda8d202678946 100644 (file)
@@ -136,7 +136,7 @@ def download(args):
     decrypt_chunks_in_place(args.key, path_in_tmp)
     print(f'{args.path} decrypted.')
 
-    if zipfile.is_zipfile(path_in_tmp):
+    if zipfile.is_zipfile(path_in_tmp) and not args.leave_as_archive:
         os.makedirs(args.output, exist_ok=True)
         shutil.unpack_archive(path_in_tmp, extract_dir=args.output, format='zip')
         print(f'Unarchived to {args.output}.')
@@ -226,6 +226,8 @@ if __name__ == '__main__':
     download_parser.add_argument('-t', dest='token', required=True,
         type=lambda x : file_path(parser, x), help='File with the '
         'authentication token.')
+    download_parser.add_argument('--leave-as-archive', action='store_true',
+        help='Do not unarchive a directory after download.')
     download_parser.set_defaults(func=download)
 
     upload_parser = subparsers.add_parser('upload', help='Upload a file. '