Fixed #20780 -- Get rid of stale symlinks when using collectstatic.
Thanks to John Giannelos for the initial patch.
This commit is contained in:
parent
6a9ed7d403
commit
f90be002d9
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue