MDL-33032 Fixed issues for file integration

1. Added tracker issue number in comment
2. Fixed stored_file::delete_reference()
3. repository::send_file() will throw exception if not implemented by subclass
4. Fixed renaming unit test, added one unit test for deleting original file
5. Fixed copyright statement for googledoc and picasa repository plugin
6. Implemented stored_file::set_filesize()
This commit is contained in:
Dongsheng Cai
2012-05-21 11:57:56 +08:00
committed by Marina Glancy
parent 4712676dfa
commit 61506a0af9
10 changed files with 145 additions and 13 deletions
+13 -4
View File
@@ -375,7 +375,7 @@ function file_prepare_draft_area(&$draftitemid, $contextid, $component, $fileare
continue;
}
$draftfile = $fs->create_file_from_storedfile($file_record, $file);
// XXX: This is a hack for file manager
// XXX: This is a hack for file manager (MDL-28666)
// File manager needs to know the original file information before copying
// to draft area, so we append these information in mdl_files.source field
// {@link file_storage::search_references()}
@@ -679,9 +679,13 @@ function file_get_submitted_draft_itemid($elname) {
*/
function file_restore_source_field_from_draft_file($storedfile) {
$source = unserialize($storedfile->get_source());
if (!empty($source) && is_object($source)) {
$restoredsource = $source->source;
$storedfile->set_source($restoredsource);
if (!empty($source)) {
if (is_object($source)) {
$restoredsource = $source->source;
$storedfile->set_source($restoredsource);
} else {
throw new moodle_exception('invalidsourcefield', 'error');
}
}
return $storedfile;
}
@@ -813,6 +817,11 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea
$oldfile->set_sortorder($newfile->get_sortorder());
}
// Update file size
if ($oldfile->get_filesize() != $newfile->get_filesize()) {
$oldfile->set_filesize($newfile->get_filesize());
}
// unchanged file or directory - we keep it as is
unset($newhashes[$oldhash]);
if (!$oldfile->is_directory()) {