Browse Source

Delete bucket files not present on disk

DricomDragon 4 years ago
parent
commit
e46225bbc8
1 changed files with 12 additions and 0 deletions
  1. 12 0
      boto-updater.py

+ 12 - 0
boto-updater.py

@@ -36,3 +36,15 @@ for file_name in local_file_list:
 
 print("Done")
 
+# Delete files
+print("Deleting removed files ...")
+for file_name in bucket_file_list:
+    print(file_name, end=' ')
+
+    if file_name in local_file_list:
+        print('(Still present)')
+    else:
+        s3.delete_object(Bucket=bucket_target, Key=file_name)
+        print('(Deleted)')
+
+print("Done")