filedir Clean up in Windows

Re: filedir Clean up in Windows

by Leon Stringer -
Number of replies: 0
Picture of Core developers Picture of Particularly helpful Moodlers

If it's the case that there's something going wrong in Moodle or the environment (e.g. Apache crashing mid-operation) causing these files to get left behind in moodledata\filedir then the Moosh utility has a check, file-dbcheck, which reports files in filedir that aren't in the database.

I had a quick go at a simple script to do this. To run it: save it, go to the command line, change to the Moodle source code folder (e.g. cd C:\MoodleWindowsInstaller-latest-33\server\moodle), and run it with PHP (e.g. C:\MoodleWindowsInstaller-latest-33\server\php\php -f C:\path\to\orphan.php). If everything is fine you should get no output. If there are any files Moodle has somehow lost they'll be listed, e.g.:

Not in database: 9a/91/91cfeee5884a43a4650a851f4f85e7b28316fcc9

Any files listed Moodle doesn't know about so they can almost certainly be deleted but I'd recommend taking a backup copy before deleting them just in case

Average of ratings: Useful (1)