Sephiron wrote:
Would doing something like this break anything I don't know about? Can similar functionality be added to upcoming updates?
The idea here is to first perform the normal purge, then check how much memory is used, if more than desired percentage, then start purging oldest files until it is enough. ie. if maxSpaceAvailable is 96, then it will start purging files until there is at least 4% of free memory space on the disk.
Thanks for sharing that. Something like that would work, particularly in a dedicated camera single SD card environment and it would be a useful addition.
Few comments.
I'm not sure about df output with external mounted media storage. I suspect that needs to be df -h /var/www/media to make sure the free space is done for the actual filing system in use. Anybody confirm that is the case?
Similarly, if the system is used for other purposes then setting absolute max storage may be more suitable for some and this avoids getting free space using df.
Maybe what is required is the ability to set it either way so user chooses which works for them.
I think the purge can be optimised a bit during this part of the cycle by building an array of files sorted by time outside of the purge loop.
The loop needs to update $maxSpaceAvailable otherwise it deletes everything!
I noticed a bug in the original code in $lapseHours is not in the OR statement.