Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
fix #68
Browse files Browse the repository at this point in the history
  • Loading branch information
antonagestam committed Jan 6, 2016
1 parent c38aaef commit 38a11de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
28 changes: 21 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ completely ignores ``modified_time``. The results of the hash lookups
are cached locally using your default Django cache. This can make
deploying much faster!


Installation
------------

Expand Down Expand Up @@ -44,6 +45,19 @@ Please note, that failure to do so will cause Django to use
even if ``AWS_PRELOAD_METADATA`` is not set to True see
`#30 <https://github.com/antonagestam/collectfast/issues/30>`_


Usage
-----

Collectfast overrides Django's builtin ``collectstatic`` command so just
run ``python manage.py collectstatic`` as normal. You can disable
collectfast by using the ``--ignore-etag`` option.

You can also disable collectfast by setting
``COLLECTFAST_ENABLED = False`` in your settings file. This is useful
when using a local file storage backend for development.


Setup Dedicated Cache Backend
-----------------------------

Expand Down Expand Up @@ -79,16 +93,14 @@ framework. <https://docs.djangoproject.com/en/stable/topics/cache/>`_
have more than 300 static files, see
`#47 <https://github.com/antonagestam/collectfast/issues/47>`_

Usage

Debug
-----

Collectfast overrides Django's builtin ``collectstatic`` command so just
run ``python manage.py collectstatic`` as normal. You can disable
collectfast by using the ``--ignore-etag`` option.
By default, Collectfast will suppress any exceptions that happens when copying
and let Django's ``collectstatic`` handle it. To debug those suppressed errors
you can set ``COLLECTFAST_DEBUG = True`` in your Django settings file.

You can also disable collectfast by setting
``COLLECTFAST_ENABLED = False`` in your settings file. This is useful
when using a local file storage backend for development.

Contribution
------------
Expand All @@ -97,6 +109,7 @@ Please feel free to contribute by using issues and pull requests.
Discussion is open and welcome. Testing is currently being implemented
and will be mandatory for new features once merged.


License
-------

Expand All @@ -106,6 +119,7 @@ Collectfast is licensed under a `Creative Commons Attribution-ShareAlike
Original idea taken from `this
snippet. <http://djangosnippets.org/snippets/2889/>`__


.. |Downloads| image:: https://img.shields.io/pypi/dm/collectfast.svg
:target: https://pypi.python.org/pypi/Collectfast
.. |Build Status| image:: https://api.travis-ci.org/antonagestam/collectfast.svg?branch=master
Expand Down
6 changes: 6 additions & 0 deletions collectfast/management/commands/collectstatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@


collectfast_cache = getattr(settings, "COLLECTFAST_CACHE", "default")

if VERSION >= (1, 7):
from django.core.cache import caches
cache = caches[collectfast_cache]
else:
from django.core.cache import get_cache
cache = get_cache(collectfast_cache)

debug = getattr(
settings, "COLLECTFAST_DEBUG", getattr(settings, "DEBUG", False))


class Command(collectstatic.Command):

Expand Down Expand Up @@ -133,6 +137,8 @@ def copy_file(self, path, prefixed_path, source_storage):
else:
self.log("Hashes did not match", level=2)
except Exception as e:
if debug:
raise
# Ignore errors and let super Command handle it
self.stdout.write(smart_str(
"Ignored error in Collectfast:\n%s\n--> Continuing using "
Expand Down

0 comments on commit 38a11de

Please sign in to comment.