Working with alias files

Re: Working with alias files

by Luis de la Torre -
Number of replies: 0

Ok, so I found out I was doing a couple of things wrong, but the biggest problem is what seems to be a bug in Moodle.


My alias was pointing to a .jar file stored in a Moodle file system repository. I was using $file->sync_external_file() to synchronized my alias with the source file in the repository. And it wasn't working. This was due a strange clause in the sync_external_file() function implementation in repository/filesystem/lib.php:


if (file_extension_in_typegroup($filepath, 'web_image')) {
$contenthash = sha1_file($filepath);
if ($file->get_contenthash() == $contenthash) {
// File did not change since the last synchronisation.
$filesize = filesize($filepath);
} else {
// Copy file into moodle filepool (used to generate an image thumbnail).
list($contenthash, $filesize, $newfile) = $fs->add_file_to_pool($filepath);
}
} else {
// Update only file size so file will NOT be copied into moodle filepool.
$contenthash = null;
$filesize = filesize($filepath);
}


That first "if" clause is only allowing image files to be synchronized. I don't think that's the actual behaviour this function should have, or is it? If I just remove that first "if()... else", my plugin works fine with aliases.


I created an issue in the tracker: https://tracker.moodle.org/browse/MDL-49621 

Average of ratings: Useful (1)