See {T320675} for background info. The concern is that Phonos could generate many orphaned files, especially during preview, that are forever lost in the abyss of Swift. During our initial rollout, we want to monitor how many orphaned files there are. A rough technical plan to accomplish this would be:
# Loop through the pages on a wiki that are in Category:Pages_that_use_Phonos
# Fetch the HTML via RESTBase (as it's really fast)
# Use an XML parser to find elements with `.ext-phonos-PhonosButton`
# Get the value of the `src=` attribute (the link to the file)
# Keep track of all the file paths
# Loop through directories under /phonos and surface files that aren't being used
Note that this maintenance script **will not scale** and is only intended for early monitoring.
**Acceptance criteria**
* Running the maintenance script should print to stdout the files that aren't being used.
* For now, the script will run on only one wiki at a time, so you will need to specify which wiki to scan.
* Possibly have an option `--counts` to just get counts and not the actual file names.
* Possibly actually delete the unused files, say when a `--delete` flag is passed.
**QA notes**
You can create orphaned files by simply using Phonos, observing that a file was generated (you can do this using only preview, if you want), then removing the <phonos> tag or changing the parameters to it so that a new file is created.