From b4bb2ad13d178dd2db484c7721fd47aa3d285908 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Mon, 14 Mar 2016 05:17:05 +0200 Subject: [1.9.x] Fixed #26297 -- Fixed `collectstatic --clear` crash if storage doesn't implement path(). Backport of 28bcff82c5ed4694f4761c303294ffafbd7096ce from master --- .../staticfiles/management/commands/collectstatic.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'django') diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py index e6b6198952..793c211f42 100644 --- a/django/contrib/staticfiles/management/commands/collectstatic.py +++ b/django/contrib/staticfiles/management/commands/collectstatic.py @@ -218,12 +218,16 @@ class Command(BaseCommand): smart_text(fpath), level=1) else: self.log("Deleting '%s'" % smart_text(fpath), level=1) - full_path = self.storage.path(fpath) - if not os.path.exists(full_path) and os.path.lexists(full_path): - # Delete broken symlinks - os.unlink(full_path) - else: + try: + full_path = self.storage.path(fpath) + except NotImplementedError: self.storage.delete(fpath) + else: + if not os.path.exists(full_path) and os.path.lexists(full_path): + # Delete broken symlinks + os.unlink(full_path) + else: + self.storage.delete(fpath) for d in dirs: self.clear_dir(os.path.join(path, d)) -- cgit v1.3