File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,18 @@ local_concatenated=$(mktemp)
1212n_failures=0
1313
1414while (( n_failures < 100 )) ; do
15- current_etag=$( aws s3api head-object --bucket " $bucket " --key " $key " --query ETag --output text)
15+ current_etag=$( aws s3api head-object --bucket " $bucket " --key " $key " --query ETag --output text 2> /dev/null) || {
16+ # File doesn't exist yet, create it fresh
17+ echo " File does not exist in S3, creating new file."
18+ if [[ " $key " =~ \. gz$ ]]; then
19+ gzip -c " $local_file_to_concatenate " > " $local_concatenated "
20+ else
21+ cp " $local_file_to_concatenate " " $local_concatenated "
22+ fi
23+ aws s3api put-object --bucket " $bucket " --key " $key " --body " $local_concatenated "
24+ echo " File created and uploaded successfully."
25+ exit 0
26+ }
1627 if [[ " $current_etag " == " null" ]]; then
1728 echo " Failed to retrieve ETag. Exiting."
1829 exit 1
@@ -32,7 +43,7 @@ while (( n_failures < 100 )); do
3243 gzip -c " $local_decompressed_concat " > " $local_concatenated "
3344 rm " $local_decompressed " " $local_decompressed_concat "
3445 else
35- cat $local_copy $local_file_to_concatenate > $local_concatenated
46+ cat " $local_copy " " $local_file_to_concatenate " > " $local_concatenated "
3647 fi
3748
3849
You can’t perform that action at this time.
0 commit comments