collectstatic copies wrong files to STATIC_ROOT
|Reported by:||pigletto||Owned by:||jezdez|
|Cc:||pigletto@…, slinkp@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In specific situation, in Django 1.3.1, second run of collecstatic command might copy wrong files to STATIC_ROOT. This is dangerous situation in production environment.
Attached test and patch against tags/1.3.1
This issue doesn't exist in current trunk (Django 1.4) but seems to me that it might been fixed 'accidentally' so I also attach (passing) test for current trunk.
To reproduce the issue:
- INSTALLED_APPS = ['appA', 'appB']
- static files in apps:
appA/ static/ file.js appB/ static/ file.js
- Modification date of file.js in appB is newer than modification date of file.js in appA
- run collectstatic twice
At first run everything is OK. File from appA is copied to STATIC_ROOT (as documentation says duplicate files are taken in order of apps in INSTALLED_APPS), but in second run file.js is replaced by wrong one - from appB.
This is caused by use of:
in copy_file method at collectstatic.py.
shutil.copy2 preservers original file modification date what causes that file.js from appB is considered newer than file in STATIC_ROOT.
Change History (11)
comment:1 Changed 2 years ago by jezdez
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
- Triage Stage changed from Unreviewed to Accepted