Commit f90be002 authored by Jannis Leidel's avatar Jannis Leidel
Browse files

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

Thanks to John Giannelos for the initial patch.
parent 6a9ed7d4
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+9 −0
Original line number Diff line number Diff line
@@ -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):
    """