I have a bunch of files on S3, and I need to download and update them via command line (BASH) on several devices.
What I do (as of now):
- Request the header of the file with
-I
and extract the ETag field - Check md5sum of local file
- If they don't match (or file does not exist locally yet) I download the file with
-f
to get a reliable exit status - Check
$?
of curl - If it is 0 I compare the expected md5sum with the md5sum of the downloaded file
What I would like to do:
- If the file exists locally, get md5sum of it
- Download file with
--header 'If-None-Match:<md5sum of local file>
- If exit status is 0 -> done!
My question: Can I rely on curls exit status? I.e. when the exit status is 0, is the downloaded file valid (assumed my file system is not corrupted in the meantime)?