summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorYusuke Miyazaki <miyazaki.dev@gmail.com>2015-10-12 15:34:16 +0900
committerTim Graham <timograham@gmail.com>2015-10-17 14:13:31 -0400
commit0922bbf18d3ae8f37e1823df2dbc270d33334548 (patch)
treeebc6983a0342d7c5e1996783115db7ef9f3d12bb /django
parenta3fffdca2472885a99e1ea9159a685753cd45738 (diff)
Fixed #25346 -- Allowed collectstatic to delete broken symlinks.
Diffstat (limited to 'django')
-rw-r--r--django/contrib/staticfiles/management/commands/collectstatic.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index 523f313c13..e6b6198952 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -218,7 +218,12 @@ class Command(BaseCommand):
smart_text(fpath), level=1)
else:
self.log("Deleting '%s'" % smart_text(fpath), level=1)
- self.storage.delete(fpath)
+ 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:
+ self.storage.delete(fpath)
for d in dirs:
self.clear_dir(os.path.join(path, d))