Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

s3 sync a changed file of equal size is dependent on time #406

Closed
chris-gilmore opened this issue Oct 13, 2013 · 2 comments
Closed

s3 sync a changed file of equal size is dependent on time #406

chris-gilmore opened this issue Oct 13, 2013 · 2 comments
Labels

Comments

@chris-gilmore
Copy link

Suppose you edit a file in such a way as to not change the file size and then upload it to S3.
If you then try to sync it back down elsewhere, the logic in s3/comparator.py - compare_time() will skip over this file if the local version is older.

@jamesls
Copy link
Member

jamesls commented Jan 17, 2014

Closing in favor of #599, which discusses this issue and proposes several potential solutions.

@jamesls jamesls closed this as completed Jan 17, 2014
@Bazman
Copy link

Bazman commented Dec 26, 2014

This is a bug from what I can see and nothing to do with #599. I've come across this myself where syncing down from s3 would skip files when file size was the same even though the last modified time in S3 was newer than the last modified time on the local file system and a sync was required.

As @chris-gilmore mentioned, it seems like its just because the compare_time() function is wrong.

In aws-cli/awscli/customizations/s3/syncstrategy/base.py, lines 207 - 223 (as of 9f56e8f):

        if cmd == "upload" or cmd == "copy":
            if self.total_seconds(delta) >= 0:
                # Destination is newer than source.
                return True
            else:
                # Destination is older than source, so
                # we have a more recently updated file
                # at the source location.
                return False
        elif cmd == "download":

            if self.total_seconds(delta) <= 0:
                return True
            else:
                # delta is positive, so the destination
                # is newer than the source.
                return False

There shouldn't be any logic difference between the cmd == "upload" or cmd == "copy" or cmd == "download". Its comparing src file and destination file times, and so all it needs to know is if the src file is newer than the destination or not.

i.e. Change the above block of code just to:

           if self.total_seconds(delta) >= 0:
                # Destination is newer than source.
                return True
            else:
                # Destination is older than source, so
                # we have a more recently updated file
                # at the source location.
                return False

This same code was also in an issue in earlier versions where the sync strategies weren't split out, and the comparison code was in comparator.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants