Opened 8 years ago

Last modified 8 years ago

#26297 closed Bug

collectstatic --clear throws NotImplementedError, "This backend doesn't support absolute paths." — at Version 1

Reported by: Topher Owned by: nobody
Component: contrib.staticfiles Version: 1.9
Severity: Normal Keywords: clear notimplementederror path
Cc: berker.peksag@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

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

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?:

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)

Change History (1)

comment:1 by Tim Graham, 8 years ago

Description: modified (diff)
Easy pickings: unset
Needs tests: set
Triage Stage: UnreviewedAccepted

I think something like this would make it more obvious where the exception is expected:

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.

Note: See TracTickets for help on using tickets.
Back to Top