public function test_check_real_file_tmp_info() { $raw_file_dir_path = conf('upload.types.img.tmp.raw_file_path'); if (!file_exists($raw_file_dir_path) || !($file_paths = Util_file::get_file_recursive($raw_file_dir_path))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No data.'); } foreach ($file_paths as $file_path) { $this->check_real_file_tmp_info($file_path); } if (!($file_paths = Util_file::get_file_recursive(conf('upload.types.file.tmp.raw_file_path')))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No data.'); } foreach ($file_paths as $file_path) { $this->check_real_file_tmp_info($file_path); } }
private static function execute_clean_file($file_type, $is_tmp = false) { if (!self::$absolute_execute && !\Site_Util::check_is_dev_env()) { throw new \FuelException('This task is not work at prod env.'); } $raw_file_dir_path = \Site_Upload::get_uploaded_path('raw', $file_type, $is_tmp); $cache_file_dir_path_key = 'upload.types.' . $file_type; if ($is_tmp) { $cache_file_dir_path_key .= '.tmp'; } $cache_file_dir_path_key .= '.root_path.cache_dir'; $cache_file_dir_path = DOCROOT . conf($cache_file_dir_path_key); if (!file_exists($raw_file_dir_path) && ($cache_file_dir_path && !file_exists($cache_file_dir_path))) { return "File directry '" . $raw_file_dir_path . "' not exists."; } $file_paths = \Util_file::get_file_recursive($raw_file_dir_path); if ($cache_file_dir_path) { $file_paths = array_merge($file_paths, \Util_file::get_file_recursive($cache_file_dir_path)); } if (!$file_paths) { return sprintf("No files at '%s'", $raw_file_dir_path); } $i = 0; foreach ($file_paths as $file_path) { if (self::check_file_exists_record($file_path, $is_tmp)) { continue; } \Util_file::remove($file_path); $i++; } $subject = $file_type; if ($is_tmp) { $subject .= '_tmp'; } return sprintf('%d %s removed.', $i, $subject); }