Kaydet (Commit) f90be002 authored tarafından Jannis Leidel's avatar Jannis Leidel

Fixed #20780 -- Get rid of stale symlinks when using collectstatic.

Thanks to John Giannelos for the initial patch.
üst 6a9ed7d4
......@@ -275,6 +275,8 @@ class Command(NoArgsCommand):
except OSError:
pass
try:
if os.path.lexists(full_path):
os.unlink(full_path)
os.symlink(source_path, full_path)
except AttributeError:
import platform
......
......@@ -694,6 +694,15 @@ class TestCollectionLinks(CollectionTestCase, TestDefaults):
"""
self.assertTrue(os.path.islink(os.path.join(settings.STATIC_ROOT, 'test.txt')))
def test_broken_symlink(self):
"""
Test broken symlink gets deleted.
"""
path = os.path.join(settings.STATIC_ROOT, 'test.txt')
os.unlink(path)
self.run_collectstatic()
self.assertTrue(os.path.islink(path))
class TestServeStatic(StaticFilesTestCase):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment