Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Avoid network I/O for remote storages in get_filename

  • Loading branch information...
commit 48e20b0c740d4a4d8878deae1c32115db7b539bd 1 parent ab97095
Niran Babalola niran authored
Showing with 10 additions and 6 deletions.
  1. +10 −6 compressor/base.py
16 compressor/base.py
View
@@ -74,14 +74,18 @@ def get_filepath(self, content, basename=None):
def get_filename(self, basename):
filename = None
# first try finding the file in the root
- if self.storage.exists(basename):
- try:
- filename = self.storage.path(basename)
- except NotImplementedError:
- # remote storages don't implement path, access the file locally
+ try:
+ # call path first so remote storages don't make it to exists,
+ # which would cause network I/O
+ filename = self.storage.path(basename)
+ if not self.storage.exists(basename):
+ filename = None
+ except NotImplementedError:
+ # remote storages don't implement path, access the file locally
+ if compressor_file_storage.exists(basename):
filename = compressor_file_storage.path(basename)
# secondly try to find it with staticfiles (in debug mode)
- elif self.finders:
+ if not filename and self.finders:
filename = self.finders.find(urllib.url2pathname(basename))
if filename:
return filename
Please sign in to comment.
Something went wrong with that request. Please try again.