samwilson / diagrams-extension

A MediaWiki extension that displays GraphViz, Mscgen, PlantUML, and Mermaid diagrams in wiki pages.
https://www.mediawiki.org/wiki/Extension:Diagrams
GNU General Public License v2.0
8 stars 11 forks source link

Delete local diagram files that are no longer used #50

Open samwilson opened 2 years ago

samwilson commented 2 years ago

Diagram images are rendered for every preview and page-save, and are never deleted. This means that diagram images will remain even if they're not in use anywhere on a wiki.

This does not apply when using the external rendering service.

YOUR1 commented 1 year ago

Is it not easier to write a maintenance script that removes all of the diagram images? They will be regenerated whenever a page is visited anyways..

samwilson commented 1 year ago

That would work for the default of having a diagrams/ subdirectory, but for #44 it'd have to be able to find the Diagrams files in amongst others. Perhaps it can already do that though, by looking for a pattern like Diagrams [0-9a-f]{32,32}\.[a-z]{2,5}?

It'd be slow on wikis with very many files, but perhaps that's okay. It wouldn't have to be run very often.

YOUR1 commented 1 year ago

I think you're missing a _ in the regex; but yes, I think that would do it.

samwilson commented 11 months ago

I've got the maintenance script working now (PR #74). It can delete based on the age of the files: what would a good default be? I was thinking maybe 30 days. It can always be overridden with e.g. --ttl 90.

YOUR1 commented 11 months ago

I've got the maintenance script working now (PR #74). It can delete based on the age of the files: what would a good default be? I was thinking maybe 30 days. It can always be overridden with e.g. --ttl 90.

Nice, I think 30 is good for starters, its a wild guess tho.

samwilson commented 11 months ago

Done, and released as 0.12.0.

Can probably do more here, such as adding a page parser property that records which files are in use so they don't get deleted.