Problem/Motivation
Currently, the minimum age to delete temporary files is 6 hours (configurable at /admin/config/media/file-system).
Also, it's possible to NEVER delete temporary files.
These are the current options:

In some situations, for example when doing a file cleanup by setting files temporary, you wish to delete them "Immediately (on next Cron run)". Waiting to 6 hours or settings the value in config, isn't cool and I don't see a reason why that shouldn't be provided as option?
Steps to reproduce
Go to /admin/config/media/file-system
and try to set "Delete temporary files after" to immediately. The option doesn't exist.
Proposed resolution
Add an option to delete the files "Immediately (on next Cron run)"
As "never" has a value of "0", we should use "1" for this.
Additionally I'd like to propose adding the unit (seconds?) to the documentation, currently this doesn't seem documented?
https://git.drupalcode.org/search?search=temporary_maximum_age&nav_sourc...
Remaining tasks
- Discuss
- Implement
- Test
- Release
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| delete-temporary-files.png | 28.22 KB | anybody |
Issue fork drupal-3305127
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #3
anybodyUnsure if it's worth overwriting the options label from date formatter here for this special case instead of displaying "1 Second"?
Comment #5
longwaveDoesn't adding this option allow a race condition, where a temporary file is uploaded, then cron happens to run in the background before it can be processed and converted to a permanent file? This might cause bugs that are hard to track down or reproduce. I think that is why the previous minimum was 6 hours, to avoid this situation.
Comment #6
anybodyThanks for the quick reaction @longwave. Puh, if that's the case, that's a mean trap. Perhaps that information should also be added as comment in the code?
I didn't know about this and indeed that makes it hard to implement, while I described a case where this functionality would be quite useful.
Comment #9
mstrelan commentedHad the same thought as @longwave in #5. I think this can be closed? Or feel free to repurpose to update documentation as per #6.
Comment #10
shaikhshadab00Comment #11
catch#5 is the reason and iirc it matches the form cache lifetime. Moving to 'needs more info'. All I can think of is making the option same as form cache lifetime and then making that configurable, but that seems too complicated to present in a UI.
Comment #12
smustgrave commented@anybody wonder if this should be closed out?
Comment #13
anybodyYes let's close it won't fix. It's just not worth it, while I think the use case is still there, but also edgy enough to close... Any if anyone will need it for good reasons in the future, we can reopen it and find a solution.