1. David Larlet
  2. django-storages

Pull requests

#83 Declined
Repository
ryanbagwell
Branch
default
Repository
david
Branch
default

converting s3 last modified time to local time so it can be properly compared by django to the local file modification time.

Author
  1. ryanbagwell
Reviewers
Description

This PR converts the s3 last modified file time to the local machine's time for comparison purposes. Otherwise, Django won't always delete the file if its older.

issue #167

Comments (7)

  1. Ian Lewis

    I think this is actually not the best solution as there are a number of timezones that are in play. i.e. The system timezone, the TIME_ZONE setting, the timezone as returned from S3.

    This PR uses the TIME_ZONE setting which can be different from the system timezone which is what the FileSystemStorage uses. The django docs explicitly state that it the system timezone and TIME_ZONE setting could be different (they do need to be the same on Windows though).

    I sent a message to the django-users mailing list to see if there is any consensus on which timezone to use. I have a feeling that the FileSystemStorage is going to be a de facto standard and that the system timezone is actually what we should be using.

    https://groups.google.com/forum/#!topic/django-users/pEIKxsHYN74

    1. Ian Lewis

      I'm not sure actually. Could you test and see what happens to the modified time in FileSystemStorage when the system timezone is not set?

  2. jaylett

    Having tested this more thoroughly, my previous comment is wrong; os.environ['TZ'] gets used (but that is usually set from settings.TIME_ZONE).

  3. ryanbagwell author

    Taking into consideration the above comments, I made some edits and opened a new PR - #102. This now uses the filesystem's timezone for comparison, and uses python-dateutil to parse the datestring that's provided by S3.

    Closing this PR.