Permalink
Browse files

MDL-34290 repository_filesystem: do not store files in moodle filepoo…

…l unless images
  • Loading branch information...
marinaglancy committed Aug 28, 2012
1 parent 7fa4cd1 commit 074455a6f596c9d03c1e0f10df7715046329f59e
Showing with 12 additions and 7 deletions.
  1. +12 −7 repository/filesystem/lib.php
@@ -273,17 +273,13 @@ public function get_reference_details($reference, $filestatus = 0) {
/**
* Returns information about file in this repository by reference
- * {@link repository::get_file_reference()}
- * {@link repository::get_file()}
*
* Returns null if file not found or is not readable
*
* @param stdClass $reference file reference db record
* @return stdClass|null contains one of the following:
- * - 'contenthash' and 'filesize'
- * - 'filepath'
- * - 'handle'
- * - 'content'
+ * - 'filesize' if file should not be copied to moodle filepool
+ * - 'filepath' if file should be copied to moodle filepool
*/
public function get_file_by_reference($reference) {
$ref = $reference->reference;
@@ -293,7 +289,16 @@ public function get_file_by_reference($reference) {
$filepath = $this->root_path.$ref;
}
if (file_exists($filepath) && is_readable($filepath)) {
- return (object)array('filepath' => $filepath);
+ if (file_extension_in_typegroup($filepath, 'web_image')) {
+ // return path to image files so it will be copied into moodle filepool
+ // we need the file in filepool to generate an image thumbnail
+ return (object)array('filepath' => $filepath);
+ } else {
+ // return just the file size so file will NOT be copied into moodle filepool
+ return (object)array(
+ 'filesize' => filesize($filepath)
+ );
+ }
} else {
return null;
}

0 comments on commit 074455a

Please sign in to comment.