Permalink
Browse files

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

  • Loading branch information...
1 parent 638d72c commit c24cd394486019487ccf890cec1df7d9a7f0f988 @FMCorz FMCorz committed Dec 12, 2012
Showing with 3 additions and 1 deletion.
  1. +2 −1 repository/draftfiles_ajax.php
  2. +1 −0 repository/draftfiles_manager.php
@@ -222,8 +222,9 @@
$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);
@@ -170,6 +170,7 @@
$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');

0 comments on commit c24cd39

Please sign in to comment.