The issue:
- A teacher has created a folder instance containing a number of very large files (in our case somewhere around 9GBytes in total)
- A student tries to download the folder.
- The download fails with an error message and a set of large temporary files are left in the localcache folder.
There are 2 problems here.
- The temporary file is created in the localcache folder where it should be in the temp folder.
- The download_folder.php script will run into page timeout problems when downloaded file sets are large, resulting in download failure and in temporary files not being deleted.
For the localcache issue the culprit is the get_request_storage_directory() (moodle/lib/setuplib.php:1620). The comment says that this function creates a folder in the temp directory tree, but the code creates the folder in localcache. Surely this is a bug.
In our use case a number of students may try to download folder contents simultaneously. For each student the folder content is stored twice in the temp directory, requiring 10s or 100s of GBytes of storage space. The localcache is a small fast storage area. It cannot accommodate this kind of temporary storage.a