[Django] #20780: collectstatic --link causes IOError when dangling symlink exists

60 views
Skip to first unread message

Django

unread,
Jul 19, 2013, 5:14:21 PM7/19/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+--------------------
Reporter: vdboor | Owner: nobody
Type: Bug | Status: new
Component: contrib.staticfiles | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+--------------------
When a symlink file already exists, but it's source was moved/renamed,
`collectstatic` ends with an `IOError`.

Here is a trackback example:

{{{
Linking '/srv/www/virtualenvs/demo.example.org/src/django-filebrowser-no-
grappelli-django14/filebrowser/static/filebrowser/js/FB_TinyMCE.js'
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/core/management/__init__.py", line 443, in
execute_from_command_line
utility.execute()
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 163, in handle_noargs
collected = self.collect()
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 113, in collect
handler(path, prefixed_path, storage)
File "/srv/www/virtualenvs/demo.example.org/lib/python2.6/site-
packages/django/contrib/staticfiles/management/commands/collectstatic.py",
line 275, in link_file
os.symlink(source_path, full_path)
OSError: [Errno 17] File exists
}}}

I switched moduled here, hence the symlinks of the previous "filebrowser"
were still there, but no longer pointed to an existing file.
The same also happens when one reorganized the project layout, while.

How to reproduce:

* Have a project with 1 app.
* run `./manage.py collectstatic --link`
* Rename that app, or move it to a sub package.
* run `./manage.py collectstatic --link` again.

--
Ticket URL: <https://code.djangoproject.com/ticket/20780>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 4, 2013, 2:03:39 PM8/4/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+-------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by johngian):

* status: new => assigned
* cc: johngian (added)
* needs_better_patch: => 0
* needs_tests: => 0
* owner: nobody => johngian
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:1>

Django

unread,
Aug 5, 2013, 8:31:01 AM8/5/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+-------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage:
Has patch: 1 | Unreviewed

Needs tests: 0 | Needs documentation: 0
Easy pickings: 1 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by johngian):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:2>

Django

unread,
Aug 17, 2013, 5:10:16 PM8/17/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------

Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by wim@…):

* stage: Unreviewed => Accepted


Comment:

Hehe I ran into the same issue not too long ago, when I too was dealing
with a filebrowser.

--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:3>

Django

unread,
Aug 17, 2013, 5:12:51 PM8/17/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+------------------------------------

Comment (by wim@…):

Hi John, does your patch not leave the broken link, in stead of replacing
it by the new one?

--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:4>

Django

unread,
Sep 19, 2013, 8:36:05 AM9/19/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by timo):

* easy: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:5>

Django

unread,
Nov 19, 2013, 12:14:37 PM11/19/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------

Comment (by johngian):

Hi, sorry for not showing a sign of process after that long time.
Yes, the patch I had sent left the broken link instead of replacing it.
I am attaching an updated patch that removes the dangling symlink first.

--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:6>

Django

unread,
Nov 20, 2013, 11:47:52 PM11/20/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by vajrasky):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:7>

Django

unread,
Dec 3, 2013, 8:53:24 AM12/3/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by johngian):

* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:8>

Django

unread,
Dec 3, 2013, 8:53:39 AM12/3/13
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: assigned
Component: contrib.staticfiles | Version: 1.5

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------

Comment (by johngian):

Updated patch with tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:9>

Django

unread,
Feb 9, 2014, 9:48:31 AM2/9/14
to django-...@googlegroups.com
#20780: collectstatic --link causes IOError when dangling symlink exists
-------------------------------------+------------------------------------
Reporter: vdboor | Owner: johngian
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 1.5
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+------------------------------------
Changes (by Jannis Leidel <jannis@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f90be002d9d3c10b87c74741986e2cbf9f2b858e"]:
{{{
#!CommitTicketReference repository=""
revision="f90be002d9d3c10b87c74741986e2cbf9f2b858e"
Fixed #20780 -- Get rid of stale symlinks when using collectstatic.

Thanks to John Giannelos for the initial patch.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/20780#comment:10>

Reply all
Reply to author
Forward
0 new messages