#26297: collectstatic --clear throws NotImplementedError, "This backend doesn't
support absolute paths."
-------------------------------------+-------------------------------------
     Reporter:  topher86             |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  contrib.staticfiles  |                  Version:  1.9
     Severity:  Normal               |               Resolution:
     Keywords:  clear                |             Triage Stage:  Accepted
  notimplementederror path           |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by timgraham):

 * needs_better_patch:   => 0
 * needs_tests:   => 1
 * easy:  1 => 0
 * needs_docs:   => 0
 * stage:  Unreviewed => Accepted


Old description:

> storage.py docstrings state of storage.path()
> >Storage systems that can't be accessed using open() should *not*
> implement this method.
>
> collectstatic.py does not catch this to use the implemented
> storage.delete() method on line 221
>

> {{{
> #!div style="font-size: 80%"
> Code highlighting:
>   {{{#!python
>                 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)
>   }}}
> }}}
>
> Patch?:
>
> {{{
> #!div style="font-size: 80%"
> Code highlighting:
>   {{{#!python
>                 try:
>                     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)
>                 except NotImplementedError:
>                     self.storage.delete(fpath)
>   }}}
> }}}

New description:

 storage.py docstrings state of storage.path()
 >Storage systems that can't be accessed using open() should *not*
 implement this method.

 collectstatic.py does not catch this to use the implemented
 storage.delete() method on line 221


 {{{#!python
 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)
 }}}

 Patch?:

 {{{#!python
 try:
     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)
 except NotImplementedError:
     self.storage.delete(fpath)
 }}}

--

Comment:

 I think something like this would make it more obvious where the exception
 is expected:
 {{{#!python
 try:
     full_path = self.storage.path(fpath)
 except NotImplementedError:
     self.storage.delete(fpath)
 else:
     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)
 }}}
 A test is also needed.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.1fd6cd20aa8bac71dc65c53349829dd3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to