From 264764e222a29c943c662a70777b1fa1b7d2b68e Mon Sep 17 00:00:00 2001 From: Jerome Mouneyrac Date: Thu, 1 Dec 2011 10:33:37 +0800 Subject: [PATCH] MDL-30459 when one filename already exist we bypass the execution and continue. We just return the error into the json string --- webservice/upload.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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); -- 2.43.0