Thought moosh had more then one command dealing with files .... and one did find orphans ... at one time. File-dbcheck below? then diff a raw listing?
Provides information on size of dataroot directory, dataroot/filedir subdirectory and total size of non-external files in moodle. Outpus data in json format when run using --json option.
Go through all files in Moodle data and check them for corruption. The check is to compare file's SHA to their file names.
Check that all files in DB do exist in Moodle data.
Search and list files from mdl_files table. The argument should be a valid SQL WHERE statement. Interesting columns of possible search criterias are: contextid, component, filearea, itemid, filepath, filename, userid, filesize, mimetype, status, timecreated, timemodified.
You can also use some special values:
- course=NNN to list all files that relate to a course
The output will contain some defaults or nearly all possible file information if "-a|--all" flag is provided. The meaning of the flags column is (in order):
- lowercase letter "d" if entry is a dicrectory
- "e" if external file
- "i" if a valid image
- "m" if time created and time modified differ
With "-i" option only IDs are returned. This can be used when pipe-ing into other file-related commands.
Example 1: Show all legacy files for a course, which context id is 15
moosh file-list "contextid=15 AND component='course' AND filearea='legacy'"
Example 2: Display full information on file with ID 17
moosh file-list -a id=162
Example 3: Show all files from course 6
moosh file-list course=6
Example 4: Super-combo. Get all course files and tar/bzip2 them up.
moosh file-list -i course=2 | moosh file-path -s -r | tar -C $(moosh config-get core dataroot) -T - -cjf files.tar.bz2