Opened 9 years ago

Closed 7 years ago

#26527 closed Bug (duplicate)

HashedFilesMixin StaticFileStorage can't handle nested assets

Reported by: Joshua Blum Owned by: nobody
Component: contrib.staticfiles Version: 1.9
Severity: Normal Keywords:
Cc: emorley@…, Ed Morley Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There seems to be a bug here if there are nested assets. For example, if i have index.js which references a partial index.html, if index.js is processed first, index.html -> index.<hash-key>.html. Then if index.html is processed and rehashed (i.e. this file contains references to index.png), the <hash-key> inside of index.js in incorrect, since index.html was rehashed to account for it's own static assets. It seems like instead of just substituting the pattern here, we need to recursively rehash the file so the ordering is preserved. Thoughts?

Change History (7)

comment:1 by Ed Morley, 9 years ago

Cc: emorley@… added

comment:2 by Tim Graham, 9 years ago

Easy pickings: unset
Summary: Bug in HashedFilesMixin StaticFileStorageHashedFilesMixin StaticFileStorage can't handle nested assets

Possible related tickets or duplicates: #22353, #24452.

If not, could you provide a test for Django's test suite that demonstrates the issue?

comment:3 by Joshua Blum, 9 years ago

I think the problem is similar, however the discussions in those tickets lead to a slightly different solution and wouldn't solve the problem as I've described it. This is the first ticket I am submitted, to add a test should I submit a PR or just show an example?

Version 0, edited 9 years ago by Joshua Blum (next)

comment:4 by Tim Graham, 9 years ago

For a test, I usually generate a patch and attach it to the ticket (unless you also plan to immediately start working on a fix, in which case a PR is fine).

comment:5 by David Sanders, 9 years ago

I've opened a WIP PR for this issue. This is a working fix that I've been using in production for 6 months and it works great. If you need an immediate fix joshblum, try that out, the entire storage.py file can be backported by itself (confirmed this works with 1.8.12, should work with 1.9 as well).

comment:6 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:7 by Ed Morley, 7 years ago

Cc: Ed Morley added
Resolution: duplicate
Status: newclosed

From reading the source, the problem described here should be fixed in Django 1.11, thanks to #24452.
If it's not, please could you reopen a new issue with full STR.
Many thanks :-)

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