From c5b91aad8ec5b22e3b4cce33c691b119590b1cd3 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Tue, 22 Mar 2011 21:24:06 +0100 Subject: [PATCH] Implemented a few storage methods introduced in Django 1.3 but missing in older versions of Django. Closes GH-11. --- compressor/storage.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compressor/storage.py b/compressor/storage.py index 93334bcc..8f0adea5 100644 --- a/compressor/storage.py +++ b/compressor/storage.py @@ -1,4 +1,6 @@ import gzip +from os import path +from datetime import datetime from django.core.files.storage import FileSystemStorage, get_storage_class from django.utils.functional import LazyObject @@ -21,6 +23,15 @@ def __init__(self, location=None, base_url=None, *args, **kwargs): super(CompressorFileStorage, self).__init__(location, base_url, *args, **kwargs) + def accessed_time(self, name): + return datetime.fromtimestamp(path.getatime(self.path(name))) + + def created_time(self, name): + return datetime.fromtimestamp(path.getctime(self.path(name))) + + def modified_time(self, name): + return datetime.fromtimestamp(path.getmtime(self.path(name))) + def get_available_name(self, name): """ Deletes the given file if it exists.