Merge pull request #686 from kijin/pr/delete-empty-folders

빈 폴더 자동 삭제 및 일괄 삭제
This commit is contained in:
Kijin Sung 2017-02-05 22:57:02 +09:00 committed by GitHub
commit 607e9357c2
13 changed files with 395 additions and 52 deletions

View file

@ -987,10 +987,13 @@ class fileController extends file
if(!$output->toBool()) return $output;
// If successfully deleted, remove the file
FileHandler::removeFile($uploaded_filename);
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($uploaded_filename));
// Call a trigger (after)
ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
// Remove empty directories
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($uploaded_filename)), true);
}
$oDocumentController->updateUploaedCount($documentSrlList);
@ -1014,15 +1017,9 @@ class fileController extends file
if(!is_array($file_list)||!count($file_list)) return new Object();
// Delete the file
$path = array();
$file_count = count($file_list);
for($i=0;$i<$file_count;$i++)
foreach ($file_list as $file)
{
$this->deleteFile($file_list[$i]->file_srl);
$uploaded_filename = $file_list[$i]->uploaded_filename;
$path_info = pathinfo($uploaded_filename);
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
$this->deleteFile($file->file_srl);
}
// Remove from the DB
@ -1030,12 +1027,6 @@ class fileController extends file
$args->upload_target_srl = $upload_target_srl;
$output = executeQuery('file.deleteFiles', $args);
if(!$output->toBool()) return $output;
// Remove a file directory of the document
for($i=0, $c=count($path); $i<$c; $i++)
{
FileHandler::removeBlankDir($path[$i]);
}
return $output;
}
@ -1066,12 +1057,12 @@ class fileController extends file
// Determine the file path by checking if the file is an image or other kinds
if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename))
{
$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
$path = sprintf("./files/attach/images/%s/%s", $target_module_srl, getNumberingPath($target_srl, 3));
$new_file = $path . $file_info->source_filename;
}
else
{
$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
$path = sprintf("./files/attach/binaries/%s/%s", $target_module_srl, getNumberingPath($target_srl, 3));
$new_file = $path . Rhymix\Framework\Security::getRandom(32, 'hex');
}
// Pass if a target document to move is same
@ -1080,6 +1071,8 @@ class fileController extends file
FileHandler::makeDir($path);
// Move the file
FileHandler::rename($old_file, $new_file);
// Delete old path
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($old_file)), true);
// Update DB information
$args = new stdClass;
$args->file_srl = $file_info->file_srl;

View file

@ -15,6 +15,7 @@
<condition operation="notin" column="files.module_srl" var="exclude_module_srl" pipe="and" />
<condition operation="equal" column="files.isvalid" var="isvalid" pipe="and" />
<condition operation="equal" column="files.direct_download" var="direct_download" pipe="and" />
<condition operation="below" column="files.regdate" var="regdate_before" pipe="and" />
<group pipe="and">
<condition operation="like" column="files.source_filename" var="s_filename" pipe="or" />
<condition operation="more" column="files.file_size" var="s_filesize_more" pipe="or" />