Trying to find what part of moodle writes this file

Trying to find what part of moodle writes this file

by Diane Soini -
Number of replies: 6

I cannot find anything searching through the code to help me find where this file gets written. It's written to the localcache directory inside a folder with a hash as the folder name. The file name looks like this:

3f9b2ef9-96fd-40d2-90ca-7653498d00c0Assignment images-20210208.zip.akfos9
0f9d9aaf-7699-417b-9939-c477fbb1b2d8Assignment images-20210208.zip.rdqst2
a322c22c-36b3-4688-ae50-96390b85bf54Assignment images-20210208.zip.8yt68t

I've done all kinds of searches and just cannot find where in the code this file is created. Any thoughts?

Average of ratings: -
In reply to Diane Soini

Re: Trying to find what part of moodle writes this file

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
HI,

Why do you need to find out - these are cache items so are likely to be destroyed or refreshed at some point? Do they not get deleted if you clear the cache? I would think that if you needed to delete them - i.e. that maybe left over due to a broken request - it should be fairly safe to do so. Disclaimer: move them elsewhere on the disk just in case it breaks something.
In reply to Benjamin Ellis

Re: Trying to find what part of moodle writes this file

by Diane Soini -
I want to find where in the application this is happening because I need to understand what is going on here. We are a very large and active university. There are over 2 billion queries per second happening in our moodle instance and we have several terrabytes of files stored and a database that is also terrabytes in size. We are searching everywhere we can for ways we can improve the performance, scalability and stability of our system. These files accumulate, do not automatically disappear after a while, and appear to serve no purpose.
In reply to Diane Soini

Re: Trying to find what part of moodle writes this file

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Hi,

But those files actually help with performance as they are caching files - i.e. they save on complex DB queries. I am surprised that you say they do not disappear - I would suggest they probably do and are replaced by new 'cache' files with updated data. Did you try clearing the cache and see if the files are removed? Please note, the site will slow down considerably if you do clear the cache until all the cache items are re-created. It might be work reading https://docs.moodle.org/dev/The_Moodle_Universal_Cache_(MUC) for an overview of Moodle caching and refer to https://docs.moodle.org/310/en/Server_cluster which covers how to set up caching for cluster installations. I apologise if anything I have mentioned you already know.
In reply to Diane Soini

Re: Trying to find what part of moodle writes this file

by Luis de Vasconcelos -
Those look like temporary files generated by Moodle. The "Assignment" in the name suggests that it's a temporary file generated by the assignment activity - perhaps files uploaded by students into a Assignment activity.

And the file names contain "zip":
3f9b2ef9-96fd-40d2-90ca-7653498d00c0Assignment images-20210208.zip.akfos9
so that suggests that these are temporary .zip files. You could download one of those files and rename them to .zip:

3f9b2ef9-96fd-40d2-90ca-7653498d00c0Assignment images-20210208.zip.akfos9 > 3f9b2ef9-96fd-40d2-90ca-7653498d00c0Assignment images-20210208.zip

Then open the .zip file in your favourite zip program and see if it is a valid zip archive. If it is the contents might give you some clues as to what the files are and in what courses they originate from.
In reply to Diane Soini

Re: Trying to find what part of moodle writes this file

by Diane Soini -
We figured out what was going on. mod_folder uses localcache as a scratch space to create a zip file when you click on "download folder". We had localcachedir pointing at ramfs and download folder used up all the space. The folder was named "Assignment images".
In reply to Diane Soini

Re: Trying to find what part of moodle writes this file

by Dan Marsden -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
not sure if it's of interest for you but we (Catalyst) IT) pushed changes through to Moodle 3.11 that change the way the folder (and assignment) build the download-all package works so that it uses the PHP Zip streaming library (and no longer uses localcachedir like that.)

but... there are several other things that still use localcachedir in a similar way, so you still need a decent amount of space available for it to use.