Commits

Alan Justino  committed b2a0d86

Keep modified_time from master on cache, if possible

  • Participants
  • Parent commits 1954fcf

Comments (0)

Files changed (1)

File storages/backends/filecache.py

 from django.core.files.storage import Storage
 from storages.utils import import_attribute
 
+import time
 import logging
 logger = logging.getLogger(__name__)
 
         """
         try:
             destiny.save(name, origin.open(name))
+            try: # If destiny have 'path', keep mtime
+                mtime = origin.modified_time(name)
+                timestamp = time.mktime(mtime.timetuple())
+                os.utime(destiny.path(name), (timestamp, timestamp))
+            except (NotImplementedError, IOError):
+                pass
+
             return True
         except Exception, e:
             logger.error("Unable to transfer '%s' from storage '%s' to '%s." %