Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return of the prodigal THUMBNAIL_FORCE_OVERWRITE #408

Merged
merged 4 commits into from
Oct 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sorl/thumbnail/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_thumbnail(self, file_, geometry_string, **options):

# We have to check exists() because the Storage backend does not
# overwrite in some implementations.
if not thumbnail.exists():
if settings.THUMBNAIL_FORCE_OVERWRITE or not thumbnail.exists():
try:
source_image = default.engine.get_image(source)
except IOError as e:
Expand Down
4 changes: 4 additions & 0 deletions sorl/thumbnail/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@
# Should we flatten images by default (fixes a lot of transparency issues with
# imagemagick)
THUMBNAIL_FLATTEN = False

# Whenever we will check an existing thumbnail exists and avoid to overwrite or not.
# Set this to true if you have an slow .exists() implementation on your storage backend of choice.
THUMBNAIL_FORCE_OVERWRITE = False
10 changes: 6 additions & 4 deletions tests/.coveragerc
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[run]
source = sorl
exclude_lines =
pragma: no cover
if __name__ == .__main__.:

omit =
*/sorl-thumbnail/sorl/__init__.py
*/sorl/thumbnail/__init__.py
*/sorl/thumbnail/conf/__init__.py
*/sorl/thumbnail/admin/compat.py
*/sorl/thumbnail/admin/__init__.py
*/sorl/thumbnail/compat.py
*/sorl/thumbnail/compat.py

[report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.: