|
@@ -14,19 +14,23 @@ s3 = boto3.client('s3', use_ssl=False, endpoint_url="http://172.17.0.2:9000", aw
|
|
|
# Get file list
|
|
|
# Source : https://stackoverflow.com/questions/3207219/how-do-i-list-all-files-of-a-directory
|
|
|
local_file_list = os.listdir(folder_to_sync)
|
|
|
+bucket_file_list = [obj['Key'] for obj in s3.list_objects(Bucket=bucket_target)['Contents']]
|
|
|
print("Local : ", folder_to_sync)
|
|
|
print(local_file_list)
|
|
|
|
|
|
# Upload
|
|
|
-print("Uploading ...")
|
|
|
+print("Uploading new files ...")
|
|
|
for file_name in local_file_list:
|
|
|
print(file_name, end=' ')
|
|
|
|
|
|
file_path = folder_to_sync + '/' + file_name
|
|
|
|
|
|
- if os.path.isfile(file_path):
|
|
|
+ if file_name in bucket_file_list:
|
|
|
+ # Todo : compare modification dates
|
|
|
+ print('(Not updated)')
|
|
|
+ elif os.path.isfile(file_path):
|
|
|
res = s3.upload_file(file_path, bucket_target, file_name)
|
|
|
- print('ok')
|
|
|
+ print('(New file)')
|
|
|
else:
|
|
|
print('(Skipped)')
|
|
|
|