]> git.ekhem.eu.org Git - gdrive_knife.git/commitdiff
Remove temporary file after upload and download.
authorJakub Czajka <jakub@ekhem.eu.org>
Wed, 8 Nov 2023 20:09:02 +0000 (21:09 +0100)
committerJakub Czajka <jakub@ekhem.eu.org>
Sun, 19 Nov 2023 13:58:52 +0000 (14:58 +0100)
gdrive_knife.py

index 81e3076a7cc7d377244387be74742288445279fc..605ea7e2518da0a2a4203e685a9bb7c891a8aa93 100644 (file)
@@ -146,6 +146,10 @@ def download(args):
         shutil.move(path_in_tmp, destination)
         print(f'Moved to {destination}.')
 
+    if os.path.exists(path_in_tmp):
+        os.remove(path_in_tmp)
+        print(f'Removed {path_in_tmp}.')
+
 def upload(args):
     drive = get_drive_client(args.token)
 
@@ -178,6 +182,9 @@ def upload(args):
         drive.files().create(body=body, media_body=media).execute()
         print(f'Created {path} on drive.')
 
+    os.remove(path_in_tmp)
+    print(f'Removed {path_in_tmp}.')
+
 def delete(args):
     drive = get_drive_client(args.token)