What value is mdl_files.size, and how is it converted to KB on the restorefile.php page?

What value is mdl_files.size, and how is it converted to KB on the restorefile.php page?

by Matthew Willis -
Number of replies: 2


The page lists the file size as 6MB here, but it is 5802 in the database. This doesn't convert cleanly from what I know. How does this page convert mdl_file.size column?
Average of ratings: -
In reply to Matthew Willis

Re: What value is mdl_files.size, and how is it converted to KB on the restorefile.php page?

by Colin Fraser -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers
mmm I've thought of file sizes as more like guidelines rather than hard and fast rules. It doesn't matter the environment, file sizes vary depending on the viewing format, I've found. You have two different views here, the Course backup area Size and the database size, What would it be if you downloaded it and had a look in your file manager, or in a DOS window or a terminal window, the results would likely be different, I suggest. However, I would also suggest it is rounded to the nearest kb in the php file that writes the page.
In reply to Colin Fraser

Re: What value is mdl_files.size, and how is it converted to KB on the restorefile.php page?

by Matthew Willis -

It's reading as a 7KB file, so you're right. Can you confirm the column stores the data as bytes? I've guessed it has, but can't find anything in the schema that confirms this. If it does, then I'm happy to use my existing conversion (to mebibityes) as below:

select f.filesize/1048576 'filesize in MB'-- 1 Mebibyte = 1048576 bytes
from mdl_files f
where (f.component = 'user' and f.filearea = 'backup')
    or (f.component = 'backup' and f.filearea = 'course')