Opened 2 months ago

Closed 2 months ago

#35593 closed Uncategorized (needsinfo)

collectstatic does not preserve source file timestamps

Reported by: Kaarle Ritvanen Owned by:
Component: contrib.staticfiles Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The collectstatic management command interacts badly with Linux package managers.

When collectstatic copies files, the last modified timestamp of the destination file gets set to the time when the command was run. If the destination file already exists and the corresponding source file does not have a newer timestamp, copying is skipped.

When files are installed by pip, the timestamps are set according to the installation time. However, this may not be the case with other package managers, such as rpm or dpkg. With native package mangers, the timestamps often reflect the build time of the package instead of the installation time. Therefore, collectstatic may skip source files that were actually updated by the package manager if the source package was built before the destination file was created.

To ensure correct operation, the destination directory must currently be emptied if any of the source files comes from the Linux distro. The suggested solution is to copy the timestamp of the source file to the destination file instead of using the current time.

Change History (1)

comment:1 by Sarah Boyce, 2 months ago

Resolution: needsinfo
Status: newclosed

I'm not sure if the right approach would be to write a custom storage here and updating the logic of Storage.get_modified_time()
Can you provide some specific details on how to reproduce this? Maybe even a test case?

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