Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-30459 when one filename already exist we bypass the execution and…

… continue. We just return the error into the json string
  • Loading branch information...
commit 264764e222a29c943c662a70777b1fa1b7d2b68e 1 parent 7bebeb2
@mouneyrac mouneyrac authored samhemelryk committed
Showing with 8 additions and 4 deletions.
  1. +8 −4 webservice/upload.php
View
12 webservice/upload.php
@@ -130,10 +130,14 @@
$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);
Please sign in to comment.
Something went wrong with that request. Please try again.