Rebuild jobs don't automatically clear temp files

mattrogowski

Well-known member
Affected version
2.2.15
This may not technically be a bug but I'd argue it's not really suitable for the suggestions forum in the sense that nobody is going to upvote it (tangent, but it'd be great to have a suggestions forum for developer-level suggestions, I've created suggestion threads before that are legitimate software benefits but nobody is exactly going to vote for them so they just get closed). Anyway...

If you're building a rebuild job and during the course of that rebuild job's execution you create some temporary files, these will not get automatically cleared up.

I can see in for example the XFMG rebuild scripts, it calls \XF\Util\File::cleanUpTempFiles(); - this will clear up any files created during that step. If however you don't include this (you don't realise, you forget, you call an entity/service method from the job and only add temp file creation to that function months later, you call a function that an addon extends and adds temp file creation, etc), then the temp files won't get cleaned up. This could lead to, for example, a terabyte of temp files laying around. And at that point the hourly cleanup cron, bless it, won't be able to do much to clear those up.

So, it would be handy if maybe somewhere within the job framework, it called \XF\Util\File::cleanUpTempFiles();, maybe as part of resume() or complete(). Or maybe just the default run() method. You could argue it should just be included in each job if it's needed, but as mentioned there are legitimate circumstances you may not actually realise it's needed, and it would be giving people a bit less rope to hang themselves with if these files were always cleared after each job step whether it was explicitly called or not.
 
Top Bottom