grunt-s3 icon indicating copy to clipboard operation
grunt-s3 copied to clipboard

Fix bug so that sync verify works with gzip correctly

Open giratikanon opened this issue 11 years ago • 1 comments

Currently, if you try to sync files with verify: true and gzip: true, it compares the md5 of the gzipped remote file with the non-gzipped local file, so the hashes never match.

So if the local file is newer, sync will always upload, regardless of whether the content changed. For example, when a cron runs every minute and writes out a data file, it will always be uploaded to S3 even if the content is the same as the remote file.

This fixes the problem by just gzipping the local file before getting the md5 hash, assuming gzip: true. It could be more efficient by caching the gzipped file and using it for upload later. In practice, even uploading 100+ files, it still takes just a second or two, the same as before.

giratikanon avatar Dec 05 '13 16:12 giratikanon

Nice catch. Could you add some tests that confirm that verify+gzip behavior is fixed, and make sure this passes CI?

zdexter avatar Dec 11 '13 06:12 zdexter