Skip to content

Commit

Permalink
support cloud completely
Browse files Browse the repository at this point in the history
  • Loading branch information
tuan-nng committed Aug 13, 2019
1 parent 971c184 commit e5531f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions compressor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from compressor.exceptions import (CompressorError, UncompressableFileError,
FilterDoesNotExist)
from compressor.filters import CachedCompilerFilter
from compressor.storage import compressor_file_storage
from compressor.storage import compressor_file_storage, default_storage
from compressor.signals import post_compress
from compressor.utils import get_class, get_mod_func, staticfiles

Expand Down Expand Up @@ -180,6 +180,10 @@ def get_filecontent(self, filename, charset):
"charset %s: %s" %
(filename, charset, e))

def get_binaryfile_content(self, filename, charset):
with default_storage.open(filename) as f:
return f.read().decode(charset)

@cached_property
def parser(self):
return get_class(settings.COMPRESS_PARSER)(self.content)
Expand Down Expand Up @@ -222,7 +226,7 @@ def hunks(self, forced=False):

if kind == SOURCE_FILE:
options = dict(options, filename=value)
value = self.get_filecontent(value, charset)
value = self.get_binaryfile_content(value, charset)

if self.precompiler_mimetypes:
precompiled, value = self.precompile(value, **options)
Expand Down
4 changes: 2 additions & 2 deletions compressor/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def get_mtime(filename):
key = get_mtime_cachekey(filename)
mtime = cache.get(key)
if mtime is None:
mtime = os.path.getmtime(filename)
default_storage.get_modified_time(filename).timestamp()
cache.set(key, mtime, settings.COMPRESS_MTIME_DELAY)
return mtime
return os.path.getmtime(filename)
return default_storage.get_modified_time(filename).timestamp()


def get_hashed_mtime(filename, length=12):
Expand Down

0 comments on commit e5531f0

Please sign in to comment.