From: Jerome Mouneyrac Date: Thu, 1 Dec 2011 02:33:37 +0000 (+0800) Subject: MDL-30459 when one filename already exist we bypass the execution and continue. We... X-Git-Tag: v2.2.0-rc1~8 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=264764e222a29c943c662a70777b1fa1b7d2b68e MDL-30459 when one filename already exist we bypass the execution and continue. We just return the error into the json string --- diff --git a/webservice/upload.php b/webservice/upload.php index 43ddb3997a9..037a573537c 100644 --- a/webservice/upload.php +++ b/webservice/upload.php @@ -130,10 +130,14 @@ foreach ($files as $file) { $file_record->itemid, $file_record->filepath, $file_record->filename); if ($existingfile) { //if allow automatic rename (avoid) - throw new moodle_exception('filenameexist', 'webservice', '', $file->filename); + $fileerror = new stdClass(); + $fileerror->filename = $file->filename; + $fileerror->errortype = 'filenameexist'; + $fileerror->errormsg = get_string('filenameexist', 'webservice', $file->filename); + $results[] = $fileerror; + } else { + $stored_file = $fs->create_file_from_pathname($file_record, $file->filepath); + $results[] = $file_record; } - - $stored_file = $fs->create_file_from_pathname($file_record, $file->filepath); - $results[] = $file_record; } echo json_encode($results);