MDL-32639 files: Zipping a folder does not overwrite existing files

This commit is contained in:
Frederic Massart
2012-12-12 14:50:10 +08:00
parent aa0cd4a7ef
commit 45cff73a1b
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -222,8 +222,9 @@ switch ($action) {
$filepath = explode('/', trim($file->get_filepath(), '/'));
$filepath = array_pop($filepath);
$zipfile = repository::get_unused_filename($draftid, $parent_path, $filepath . '.zip');
if ($newfile = $zipper->archive_to_storage(array($filepath => $file), $user_context->id, 'user', 'draft', $draftid, $parent_path, $filepath.'.zip', $USER->id)) {
if ($newfile = $zipper->archive_to_storage(array($filepath => $file), $user_context->id, 'user', 'draft', $draftid, $parent_path, $zipfile, $USER->id)) {
$return = new stdClass();
$return->filepath = $parent_path;
echo json_encode($return);
+1
View File
@@ -170,6 +170,7 @@ case 'zip':
$filename = $filepath.'.zip';
}
$filename = repository::get_unused_filename($itemid, $parent_path, $filename);
$newfile = $zipper->archive_to_storage(array($filepath => $file), $user_context->id, 'user', 'draft', $itemid, $parent_path, $filename, $USER->id);
$home_url->param('action', 'browse');