@@ -186,6 +186,9 @@ discard block |
||
| 186 | 186 | return $total; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | + /** |
|
| 190 | + * @param string $backup_name |
|
| 191 | + */ |
|
| 189 | 192 | public function is_part($backup_name) |
| 190 | 193 | { |
| 191 | 194 | if(stristr($backup_name, "-part")) |
@@ -576,6 +579,9 @@ discard block |
||
| 576 | 579 | |
| 577 | 580 | } |
| 578 | 581 | |
| 582 | + /** |
|
| 583 | + * @param string $tmp_file |
|
| 584 | + */ |
|
| 579 | 585 | public function estimate_reading_time($tmp_file) |
| 580 | 586 | { |
| 581 | 587 | $this->logger->debug(sprintf(("Estimating file system reading time"))); |
@@ -634,6 +640,9 @@ discard block |
||
| 634 | 640 | //return ($a ($direction == 'desc' ? '>' : '<') $b) ? -1 : 1; |
| 635 | 641 | } |
| 636 | 642 | |
| 643 | + /** |
|
| 644 | + * @param string $field |
|
| 645 | + */ |
|
| 637 | 646 | public function sort_by( &$array, $field, $direction = 'asc') |
| 638 | 647 | { |
| 639 | 648 | $direction = strtolower($direction); |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | public function getMetadataFull($adapter = "storage_adapter" , $path) |
| 262 | - { |
|
| 263 | - $location = $this->$adapter->applyPathPrefix($path); |
|
| 264 | - $spl_info = new SplFileInfo($location); |
|
| 262 | + { |
|
| 263 | + $location = $this->$adapter->applyPathPrefix($path); |
|
| 264 | + $spl_info = new SplFileInfo($location); |
|
| 265 | 265 | |
| 266 | - return ($spl_info); |
|
| 267 | - } |
|
| 266 | + return ($spl_info); |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | public function get_backup_archives_list() |
@@ -619,28 +619,28 @@ discard block |
||
| 619 | 619 | global $field, $direction; |
| 620 | 620 | |
| 621 | 621 | $a = $a["' . $field . '"]; |
| 622 | - $b = $b["' . $field . '"]; |
|
| 622 | + $b = $b["' . $field . '"]; |
|
| 623 | 623 | |
| 624 | - if ($a == $b) |
|
| 625 | - { |
|
| 626 | - return 0; |
|
| 627 | - } |
|
| 624 | + if ($a == $b) |
|
| 625 | + { |
|
| 626 | + return 0; |
|
| 627 | + } |
|
| 628 | 628 | |
| 629 | 629 | if(strlower($direction) == 'desc' ) |
| 630 | 630 | return ($a > $b) ? -1 : 1; |
| 631 | 631 | else |
| 632 | 632 | return ($a < $b) ? -1 : 1; |
| 633 | 633 | |
| 634 | - //return ($a ($direction == 'desc' ? '>' : '<') $b) ? -1 : 1; |
|
| 634 | + //return ($a ($direction == 'desc' ? '>' : '<') $b) ? -1 : 1; |
|
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | public function sort_by( &$array, $field, $direction = 'asc') |
| 638 | 638 | { |
| 639 | 639 | $direction = strtolower($direction); |
| 640 | 640 | |
| 641 | - usort($array, array($this, sort_by_usort)); |
|
| 641 | + usort($array, array($this, sort_by_usort)); |
|
| 642 | 642 | |
| 643 | - return true; |
|
| 643 | + return true; |
|
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | public function is_excluded($file) |
@@ -4,12 +4,12 @@ discard block |
||
| 4 | 4 | use League\Flysystem\Util; |
| 5 | 5 | use League\Flysystem\Adapter\Local; |
| 6 | 6 | |
| 7 | -class Xcloner_File_System{ |
|
| 7 | +class Xcloner_File_System { |
|
| 8 | 8 | |
| 9 | - private $excluded_files = ""; |
|
| 10 | - private $excluded_files_by_default = array("administrator/backups", "wp-content/backups"); |
|
| 11 | - private $included_files_handler = "backup_files.csv"; |
|
| 12 | - private $temp_dir_handler = ".dir"; |
|
| 9 | + private $excluded_files = ""; |
|
| 10 | + private $excluded_files_by_default = array("administrator/backups", "wp-content/backups"); |
|
| 11 | + private $included_files_handler = "backup_files.csv"; |
|
| 12 | + private $temp_dir_handler = ".dir"; |
|
| 13 | 13 | public $filesystem; |
| 14 | 14 | public $tmp_filesystem; |
| 15 | 15 | public $storage_filesystem; |
@@ -32,39 +32,39 @@ discard block |
||
| 32 | 32 | $this->logger = new XCloner_Logger('xcloner_file_system', $hash); |
| 33 | 33 | $this->xcloner_requirements = new Xcloner_Requirements(); |
| 34 | 34 | |
| 35 | - $this->xcloner_settings = new Xcloner_Settings($hash); |
|
| 35 | + $this->xcloner_settings = new Xcloner_Settings($hash); |
|
| 36 | 36 | |
| 37 | - try{ |
|
| 37 | + try { |
|
| 38 | 38 | |
| 39 | - $this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 39 | + $this->start_adapter = new Local($this->xcloner_settings->get_xcloner_start_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 40 | 40 | $this->start_filesystem = new Filesystem($this->start_adapter, new Config([ |
| 41 | 41 | 'disable_asserts' => true, |
| 42 | 42 | ])); |
| 43 | 43 | |
| 44 | - $this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 44 | + $this->tmp_adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 45 | 45 | $this->tmp_filesystem = new Filesystem($this->tmp_adapter, new Config([ |
| 46 | 46 | 'disable_asserts' => true, |
| 47 | 47 | ])); |
| 48 | - $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(),LOCK_EX|FILE_APPEND, 'SKIP_LINKS'); |
|
| 48 | + $adapter = new Local($this->xcloner_settings->get_xcloner_tmp_path(), LOCK_EX | FILE_APPEND, 'SKIP_LINKS'); |
|
| 49 | 49 | $this->tmp_filesystem_append = new Filesystem($adapter, new Config([ |
| 50 | 50 | 'disable_asserts' => true, |
| 51 | 51 | ])); |
| 52 | 52 | |
| 53 | - $adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),LOCK_EX, 'SKIP_LINKS'); |
|
| 53 | + $adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), LOCK_EX, 'SKIP_LINKS'); |
|
| 54 | 54 | $this->storage_filesystem = new Filesystem($adapter, new Config([ |
| 55 | 55 | 'disable_asserts' => true, |
| 56 | 56 | ])); |
| 57 | 57 | |
| 58 | - $this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(),FILE_APPEND, 'SKIP_LINKS'); |
|
| 58 | + $this->storage_adapter = new Local($this->xcloner_settings->get_xcloner_store_path(), FILE_APPEND, 'SKIP_LINKS'); |
|
| 59 | 59 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
| 60 | 60 | 'disable_asserts' => true, |
| 61 | 61 | ])); |
| 62 | - }catch(Exception $e){ |
|
| 62 | + }catch (Exception $e) { |
|
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - if($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 67 | + if ($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 68 | 68 | $this->folders_to_process_per_session = $value; |
| 69 | 69 | |
| 70 | 70 | } |
@@ -125,10 +125,10 @@ discard block |
||
| 125 | 125 | return $this->getMetadataFull('storage_adapter', $file); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - public function get_included_files_handler($metadata = 0) |
|
| 128 | + public function get_included_files_handler($metadata = 0) |
|
| 129 | 129 | { |
| 130 | 130 | $path = $this->included_files_handler; |
| 131 | - if(!$metadata) |
|
| 131 | + if (!$metadata) |
|
| 132 | 132 | return $path; |
| 133 | 133 | |
| 134 | 134 | $spl_info = $this->getMetadataFull('tmp_adapter', $path); |
@@ -145,16 +145,16 @@ discard block |
||
| 145 | 145 | { |
| 146 | 146 | $files = $this->get_backup_archives_list(); |
| 147 | 147 | |
| 148 | - if(is_array($files)) |
|
| 149 | - $this->sort_by($files, "timestamp","desc"); |
|
| 148 | + if (is_array($files)) |
|
| 149 | + $this->sort_by($files, "timestamp", "desc"); |
|
| 150 | 150 | |
| 151 | 151 | $new_list = array(); |
| 152 | 152 | |
| 153 | - foreach($files as $key=>$file) |
|
| 154 | - if(!isset($file['parent'])) |
|
| 153 | + foreach ($files as $key=>$file) |
|
| 154 | + if (!isset($file['parent'])) |
|
| 155 | 155 | $new_list[] = ($files[$key]); |
| 156 | 156 | |
| 157 | - if(isset($new_list[0])) |
|
| 157 | + if (isset($new_list[0])) |
|
| 158 | 158 | return $new_list[0]; |
| 159 | 159 | } |
| 160 | 160 | |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $files = $this->get_backup_archives_list(); |
| 164 | 164 | |
| 165 | - if(is_array($files)) |
|
| 166 | - $this->sort_by($files, "timestamp","desc"); |
|
| 165 | + if (is_array($files)) |
|
| 166 | + $this->sort_by($files, "timestamp", "desc"); |
|
| 167 | 167 | |
| 168 | 168 | $new_list = array(); |
| 169 | 169 | |
| 170 | - foreach($files as $key=>$file) |
|
| 171 | - if(!isset($file['parent'])) |
|
| 170 | + foreach ($files as $key=>$file) |
|
| 171 | + if (!isset($file['parent'])) |
|
| 172 | 172 | $new_list[] = ($files[$key]); |
| 173 | 173 | |
| 174 | 174 | return $new_list; |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | $files = $this->get_backup_archives_list(); |
| 180 | 180 | $total = 0; |
| 181 | 181 | |
| 182 | - if(is_array($files)) |
|
| 183 | - foreach($files as $file) |
|
| 182 | + if (is_array($files)) |
|
| 183 | + foreach ($files as $file) |
|
| 184 | 184 | $total += $file['size']; |
| 185 | 185 | |
| 186 | 186 | return $total; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | public function is_part($backup_name) |
| 190 | 190 | { |
| 191 | - if(stristr($backup_name, "-part")) |
|
| 191 | + if (stristr($backup_name, "-part")) |
|
| 192 | 192 | return true; |
| 193 | 193 | |
| 194 | 194 | return false; |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | |
| 197 | 197 | public function is_multipart($backup_name) |
| 198 | 198 | { |
| 199 | - if(stristr($backup_name, "-multipart")) |
|
| 199 | + if (stristr($backup_name, "-multipart")) |
|
| 200 | 200 | return true; |
| 201 | 201 | |
| 202 | 202 | return false; |
@@ -205,10 +205,10 @@ discard block |
||
| 205 | 205 | public function get_backup_size($backup_name) |
| 206 | 206 | { |
| 207 | 207 | $backup_size = $this->get_storage_filesystem()->getSize($backup_name); |
| 208 | - if($this->is_multipart($backup_name)) |
|
| 208 | + if ($this->is_multipart($backup_name)) |
|
| 209 | 209 | { |
| 210 | 210 | $backup_parts = $this->get_multipart_files($backup_name); |
| 211 | - foreach($backup_parts as $part_file) |
|
| 211 | + foreach ($backup_parts as $part_file) |
|
| 212 | 212 | $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
| 213 | 213 | } |
| 214 | 214 | |
@@ -219,12 +219,12 @@ discard block |
||
| 219 | 219 | { |
| 220 | 220 | $files = array(); |
| 221 | 221 | |
| 222 | - if($this->is_multipart($backup_name)) |
|
| 222 | + if ($this->is_multipart($backup_name)) |
|
| 223 | 223 | { |
| 224 | 224 | $lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name)); |
| 225 | - foreach($lines as $line) |
|
| 225 | + foreach ($lines as $line) |
|
| 226 | 226 | { |
| 227 | - if($line) |
|
| 227 | + if ($line) |
|
| 228 | 228 | { |
| 229 | 229 | $data = str_getcsv($line); |
| 230 | 230 | $files[] = $data[0]; |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | public function delete_backup_by_name($backup_name) |
| 239 | 239 | { |
| 240 | - if($this->is_multipart($backup_name)) |
|
| 240 | + if ($this->is_multipart($backup_name)) |
|
| 241 | 241 | { |
| 242 | 242 | $lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($backup_name)); |
| 243 | - foreach($lines as $line) |
|
| 243 | + foreach ($lines as $line) |
|
| 244 | 244 | { |
| 245 | - if($line) |
|
| 245 | + if ($line) |
|
| 246 | 246 | { |
| 247 | 247 | $data = str_getcsv($line); |
| 248 | 248 | $this->get_storage_filesystem()->delete($data[0]); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if($this->get_storage_filesystem()->delete($backup_name)) |
|
| 253 | + if ($this->get_storage_filesystem()->delete($backup_name)) |
|
| 254 | 254 | $return = true; |
| 255 | 255 | else |
| 256 | 256 | $return = false; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | return $return; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - public function getMetadataFull($adapter = "storage_adapter" , $path) |
|
| 261 | + public function getMetadataFull($adapter = "storage_adapter", $path) |
|
| 262 | 262 | { |
| 263 | 263 | $location = $this->$adapter->applyPathPrefix($path); |
| 264 | 264 | $spl_info = new SplFileInfo($location); |
@@ -271,25 +271,25 @@ discard block |
||
| 271 | 271 | { |
| 272 | 272 | $list = array(); |
| 273 | 273 | |
| 274 | - if(method_exists($this->get_storage_filesystem(), "listContents")) |
|
| 274 | + if (method_exists($this->get_storage_filesystem(), "listContents")) |
|
| 275 | 275 | $list = $this->get_storage_filesystem()->listContents(); |
| 276 | 276 | |
| 277 | 277 | |
| 278 | 278 | $backup_files = array(); |
| 279 | 279 | $parents = array(); |
| 280 | 280 | |
| 281 | - foreach($list as $file_info) |
|
| 281 | + foreach ($list as $file_info) |
|
| 282 | 282 | { |
| 283 | 283 | $data = array(); |
| 284 | 284 | |
| 285 | - if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
| 285 | + if (isset($file_info['extension']) and $file_info['extension'] == "csv") |
|
| 286 | 286 | { |
| 287 | 287 | $lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path'])); |
| 288 | - foreach($lines as $line) |
|
| 289 | - if($line) |
|
| 288 | + foreach ($lines as $line) |
|
| 289 | + if ($line) |
|
| 290 | 290 | { |
| 291 | 291 | $data = str_getcsv($line); |
| 292 | - if(is_array($data)){ |
|
| 292 | + if (is_array($data)) { |
|
| 293 | 293 | $parents[$data[0]] = $file_info['path']; |
| 294 | 294 | $file_info['childs'][] = $data; |
| 295 | 295 | $file_info['size'] += $data[2]; |
@@ -298,13 +298,13 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 301 | + if ($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 302 | 302 | $backup_files[$file_info['path']] = $file_info; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - foreach($backup_files as $key=>$file_info) |
|
| 305 | + foreach ($backup_files as $key=>$file_info) |
|
| 306 | 306 | { |
| 307 | - if(isset($parents[$file_info['path']])) |
|
| 307 | + if (isset($parents[$file_info['path']])) |
|
| 308 | 308 | $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -313,40 +313,40 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | public function start_file_recursion($init = 0) |
| 315 | 315 | { |
| 316 | - if($init) |
|
| 316 | + if ($init) |
|
| 317 | 317 | { |
| 318 | 318 | $this->logger->info(sprintf(__("Starting the filesystem scanner on root folder %s"), $this->xcloner_settings->get_xcloner_start_path())); |
| 319 | 319 | $this->do_system_init(); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())){ |
|
| 322 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 323 | 323 | //.dir exists, we presume we have files to iterate |
| 324 | 324 | $content = $this->tmp_filesystem->read($this->get_temp_dir_handler()); |
| 325 | 325 | $files = array_filter(explode("\n", $content)); |
| 326 | 326 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 327 | 327 | |
| 328 | 328 | $counter = 0; |
| 329 | - foreach($files as $file) |
|
| 329 | + foreach ($files as $file) |
|
| 330 | 330 | { |
| 331 | - if($counter < $this->folders_to_process_per_session){ |
|
| 331 | + if ($counter < $this->folders_to_process_per_session) { |
|
| 332 | 332 | $this->build_files_list($file); |
| 333 | 333 | $counter++; |
| 334 | - }else{ |
|
| 334 | + } else { |
|
| 335 | 335 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n"); |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | - }else{ |
|
| 338 | + } else { |
|
| 339 | 339 | $this->build_files_list(); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - if($this->scan_finished()) |
|
| 342 | + if ($this->scan_finished()) |
|
| 343 | 343 | { |
| 344 | 344 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata("index.html"); |
| 345 | 345 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
| 346 | 346 | $this->files_counter++; |
| 347 | 347 | |
| 348 | 348 | //adding included dump file to the included files list |
| 349 | - if($this->get_tmp_filesystem()->has($this->get_included_files_handler())) |
|
| 349 | + if ($this->get_tmp_filesystem()->has($this->get_included_files_handler())) |
|
| 350 | 350 | { |
| 351 | 351 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->get_included_files_handler()); |
| 352 | 352 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
@@ -354,13 +354,13 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | //adding a default index.html to the temp xcloner folder |
| 357 | - if(!$this->get_tmp_filesystem()->has("index.html")) |
|
| 357 | + if (!$this->get_tmp_filesystem()->has("index.html")) |
|
| 358 | 358 | { |
| 359 | - $this->get_tmp_filesystem()->write("index.html",""); |
|
| 359 | + $this->get_tmp_filesystem()->write("index.html", ""); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | //adding the default log file |
| 363 | - if($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) |
|
| 363 | + if ($this->get_tmp_filesystem()->has($this->xcloner_settings->get_logger_filename(1))) |
|
| 364 | 364 | { |
| 365 | 365 | $metadata_dumpfile = $this->get_tmp_filesystem()->getMetadata($this->xcloner_settings->get_logger_filename(1)); |
| 366 | 366 | $this->store_file($metadata_dumpfile, 'tmp_filesystem'); |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | { |
| 378 | 378 | $return = array(); |
| 379 | 379 | $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler(); |
| 380 | - if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 380 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 381 | 381 | $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
| 382 | 382 | |
| 383 | 383 | return $return; |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | $contents = $this->get_tmp_filesystem()->listContents(); |
| 392 | 392 | |
| 393 | - if(is_array($contents)) |
|
| 394 | - foreach($contents as $file_info) |
|
| 393 | + if (is_array($contents)) |
|
| 394 | + foreach ($contents as $file_info) |
|
| 395 | 395 | $this->get_tmp_filesystem()->delete($file_info['path']); |
| 396 | 396 | |
| 397 | 397 | @rmdir($this->xcloner_settings->get_xcloner_tmp_path()); |
@@ -403,16 +403,16 @@ discard block |
||
| 403 | 403 | { |
| 404 | 404 | $this->files_counter = 0; |
| 405 | 405 | |
| 406 | - if(!$this->storage_filesystem->has("index.html")) |
|
| 407 | - $this->storage_filesystem->write("index.html",""); |
|
| 406 | + if (!$this->storage_filesystem->has("index.html")) |
|
| 407 | + $this->storage_filesystem->write("index.html", ""); |
|
| 408 | 408 | |
| 409 | - if(!$this->tmp_filesystem->has("index.html")) |
|
| 410 | - $this->tmp_filesystem->write("index.html",""); |
|
| 409 | + if (!$this->tmp_filesystem->has("index.html")) |
|
| 410 | + $this->tmp_filesystem->write("index.html", ""); |
|
| 411 | 411 | |
| 412 | - if($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 412 | + if ($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 413 | 413 | $this->tmp_filesystem->delete($this->get_included_files_handler()); |
| 414 | 414 | |
| 415 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 415 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 416 | 416 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 417 | 417 | } |
| 418 | 418 | |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | public function set_excluded_files($excluded_files = array()) |
| 435 | 435 | { |
| 436 | - if(!is_array($excluded_files)) |
|
| 436 | + if (!is_array($excluded_files)) |
|
| 437 | 437 | $excluded_files = array(); |
| 438 | 438 | |
| 439 | 439 | $this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default); |
@@ -456,33 +456,33 @@ discard block |
||
| 456 | 456 | $this->logger->debug(sprintf(("Building the files system list"))); |
| 457 | 457 | |
| 458 | 458 | //if we start with the root folder(empty value), we initializa the file system |
| 459 | - if(!$folder){ |
|
| 459 | + if (!$folder) { |
|
| 460 | 460 | |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | - try{ |
|
| 463 | + try { |
|
| 464 | 464 | |
| 465 | 465 | $files = $this->start_filesystem->listContents($folder); |
| 466 | - foreach($files as $file) |
|
| 466 | + foreach ($files as $file) |
|
| 467 | 467 | { |
| 468 | - if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
|
| 468 | + if (!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
|
| 469 | 469 | { |
| 470 | - $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE")); |
|
| 470 | + $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN", "NOT READABLE")); |
|
| 471 | 471 | } |
| 472 | - elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 473 | - $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE")); |
|
| 472 | + elseif (!$matching_pattern = $this->is_excluded($file)) { |
|
| 473 | + $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN", "INCLUDE")); |
|
| 474 | 474 | $file['visibility'] = $this->start_filesystem->getVisibility($file['path']); |
| 475 | 475 | $this->store_file($file); |
| 476 | 476 | $this->files_counter++; |
| 477 | - if(isset($file['size'])) |
|
| 477 | + if (isset($file['size'])) |
|
| 478 | 478 | $this->files_size += $file['size']; |
| 479 | 479 | |
| 480 | - }else{ |
|
| 481 | - $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE")); |
|
| 480 | + } else { |
|
| 481 | + $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN", "EXCLUDE")); |
|
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - }catch(Exception $e){ |
|
| 485 | + }catch (Exception $e) { |
|
| 486 | 486 | |
| 487 | 487 | $this->logger->error($e->getMessage()); |
| 488 | 488 | |
@@ -496,9 +496,9 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | $start_time = microtime(); |
| 498 | 498 | |
| 499 | - $data = str_repeat(rand(0,9), 1024*1024); //write 1MB data |
|
| 499 | + $data = str_repeat(rand(0, 9), 1024 * 1024); //write 1MB data |
|
| 500 | 500 | |
| 501 | - try{ |
|
| 501 | + try { |
|
| 502 | 502 | $this->tmp_filesystem->write($tmp_file, $data); |
| 503 | 503 | |
| 504 | 504 | $end_time = microtime() - $start_time; |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | $this->tmp_filesystem->delete($tmp_file); |
| 511 | 511 | |
| 512 | - }catch(Exception $e){ |
|
| 512 | + }catch (Exception $e) { |
|
| 513 | 513 | |
| 514 | 514 | $this->logger->error($e->getMessage()); |
| 515 | 515 | |
@@ -530,10 +530,10 @@ discard block |
||
| 530 | 530 | |
| 531 | 531 | $files = $this->storage_filesystem->listContents(); |
| 532 | 532 | |
| 533 | - if(is_array($files)) |
|
| 534 | - foreach($files as $file) |
|
| 533 | + if (is_array($files)) |
|
| 534 | + foreach ($files as $file) |
|
| 535 | 535 | { |
| 536 | - if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
|
| 536 | + if (isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
|
| 537 | 537 | { |
| 538 | 538 | $_storage_size += $file['size']; //bytes |
| 539 | 539 | $_backup_files_list[] = $file; |
@@ -541,15 +541,15 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | |
| 544 | - $this->sort_by($_backup_files_list, "timestamp","asc"); |
|
| 544 | + $this->sort_by($_backup_files_list, "timestamp", "asc"); |
|
| 545 | 545 | |
| 546 | 546 | $_backups_counter = sizeof($_backup_files_list); |
| 547 | 547 | |
| 548 | - foreach($_backup_files_list as $file) |
|
| 548 | + foreach ($_backup_files_list as $file) |
|
| 549 | 549 | { |
| 550 | 550 | //processing rule folder capacity |
| 551 | - if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
|
| 552 | - $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 551 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
|
| 552 | + $_storage_size >= ($set_storage_limit = 1024 * 1024 * $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 553 | 553 | { |
| 554 | 554 | $this->storage_filesystem->delete($file['path']); |
| 555 | 555 | $_storage_size -= $file['size']; |
@@ -557,14 +557,14 @@ discard block |
||
| 557 | 557 | } |
| 558 | 558 | |
| 559 | 559 | //processing rule days limit |
| 560 | - if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) |
|
| 560 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days') && $current_timestamp >= $file['timestamp']) |
|
| 561 | 561 | { |
| 562 | 562 | $this->storage_filesystem->delete($file['path']); |
| 563 | 563 | $this->logger->info("Deleting backup ".$file['path']." matching rule", array("RETENTION LIMIT TIMESTAMP", $file['timestamp']." =< ".$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_days'))); |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | //processing backup countert limit |
| 567 | - if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')) |
|
| 567 | + if ($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives') && $_backups_counter >= $this->xcloner_settings->get_xcloner_option('xcloner_cleanup_retention_limit_archives')) |
|
| 568 | 568 | { |
| 569 | 569 | $this->storage_filesystem->delete($file['path']); |
| 570 | 570 | $_backups_counter--; |
@@ -590,25 +590,25 @@ discard block |
||
| 590 | 590 | |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | - public function process_backup_name($name = "", $max_length=100) |
|
| 593 | + public function process_backup_name($name = "", $max_length = 100) |
|
| 594 | 594 | { |
| 595 | - if(!$name) |
|
| 595 | + if (!$name) |
|
| 596 | 596 | $name = $this->xcloner_settings->get_default_backup_name(); |
| 597 | 597 | |
| 598 | - foreach($this->backup_name_tags as $tag) |
|
| 598 | + foreach ($this->backup_name_tags as $tag) |
|
| 599 | 599 | { |
| 600 | - if($tag == '[time]') |
|
| 601 | - $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 602 | - elseif($tag == '[hostname]') |
|
| 603 | - $name = str_replace($tag, gethostname() ,$name); |
|
| 604 | - elseif($tag == '[domain]') |
|
| 600 | + if ($tag == '[time]') |
|
| 601 | + $name = str_replace($tag, date("Y-m-d_H-i"), $name); |
|
| 602 | + elseif ($tag == '[hostname]') |
|
| 603 | + $name = str_replace($tag, gethostname(), $name); |
|
| 604 | + elseif ($tag == '[domain]') |
|
| 605 | 605 | { |
| 606 | 606 | $domain = parse_url(admin_url(), PHP_URL_HOST); |
| 607 | - $name = str_replace($tag, $domain ,$name); |
|
| 607 | + $name = str_replace($tag, $domain, $name); |
|
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | - if($max_length) |
|
| 611 | + if ($max_length) |
|
| 612 | 612 | $name = substr($name, 0, $max_length); |
| 613 | 613 | |
| 614 | 614 | return $name; |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | return 0; |
| 627 | 627 | } |
| 628 | 628 | |
| 629 | - if(strlower($direction) == 'desc' ) |
|
| 629 | + if (strlower($direction) == 'desc') |
|
| 630 | 630 | return ($a > $b) ? -1 : 1; |
| 631 | 631 | else |
| 632 | 632 | return ($a < $b) ? -1 : 1; |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | //return ($a ($direction == 'desc' ? '>' : '<') $b) ? -1 : 1; |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - public function sort_by( &$array, $field, $direction = 'asc') |
|
| 637 | + public function sort_by(&$array, $field, $direction = 'asc') |
|
| 638 | 638 | { |
| 639 | 639 | $direction = strtolower($direction); |
| 640 | 640 | |
@@ -647,29 +647,29 @@ discard block |
||
| 647 | 647 | { |
| 648 | 648 | $this->logger->debug(sprintf(("Checking if %s is excluded"), $file['path'])); |
| 649 | 649 | |
| 650 | - if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
|
| 650 | + if ($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
|
| 651 | 651 | { |
| 652 | - if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 652 | + if (isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 653 | 653 | return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | - if(!sizeof($this->excluded_files)) |
|
| 656 | + if (!sizeof($this->excluded_files)) |
|
| 657 | 657 | $this->set_excluded_files(); |
| 658 | 658 | |
| 659 | - if(is_array($this->excluded_files)) |
|
| 660 | - foreach($this->excluded_files as $excluded_file_pattern) |
|
| 659 | + if (is_array($this->excluded_files)) |
|
| 660 | + foreach ($this->excluded_files as $excluded_file_pattern) |
|
| 661 | 661 | { |
| 662 | - if($excluded_file_pattern == "/") |
|
| 662 | + if ($excluded_file_pattern == "/") |
|
| 663 | 663 | $needle = "$"; |
| 664 | 664 | else |
| 665 | 665 | $needle = "$".$excluded_file_pattern; |
| 666 | 666 | |
| 667 | - if(strstr("$".$file['path'], $needle)){ |
|
| 667 | + if (strstr("$".$file['path'], $needle)) { |
|
| 668 | 668 | return $excluded_file_pattern; |
| 669 | 669 | } |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if( $regex = $this->is_excluded_regex($file)) |
|
| 672 | + if ($regex = $this->is_excluded_regex($file)) |
|
| 673 | 673 | return $regex; |
| 674 | 674 | |
| 675 | 675 | return false; |
@@ -715,25 +715,25 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | //print_r($regex_patterns);exit; |
| 717 | 717 | |
| 718 | - if(is_array($regex_patterns)) |
|
| 718 | + if (is_array($regex_patterns)) |
|
| 719 | 719 | { |
| 720 | 720 | //$this->excluded_files = array(); |
| 721 | 721 | //$this->excluded_files[] ="(.*)\.(git)(.*)$"; |
| 722 | 722 | //$this->excluded_files[] ="wp-content\/backups(.*)$"; |
| 723 | 723 | |
| 724 | - foreach($regex_patterns as $excluded_file_pattern) |
|
| 724 | + foreach ($regex_patterns as $excluded_file_pattern) |
|
| 725 | 725 | { |
| 726 | 726 | |
| 727 | - if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") |
|
| 728 | - $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 727 | + if (substr($excluded_file_pattern, strlen($excluded_file_pattern) - 1, strlen($excluded_file_pattern)) == "\r") |
|
| 728 | + $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern) - 1); |
|
| 729 | 729 | |
| 730 | - if($file['path'] == "/") |
|
| 730 | + if ($file['path'] == "/") |
|
| 731 | 731 | $needle = "/"; |
| 732 | 732 | else |
| 733 | 733 | $needle = "/".$file['path']; |
| 734 | 734 | //echo $needle."---".$excluded_file_pattern."---\n"; |
| 735 | 735 | |
| 736 | - if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){ |
|
| 736 | + if (@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)) { |
|
| 737 | 737 | return $excluded_file_pattern; |
| 738 | 738 | } |
| 739 | 739 | } |
@@ -746,27 +746,27 @@ discard block |
||
| 746 | 746 | { |
| 747 | 747 | $this->logger->debug(sprintf("Storing %s in the backup list", $file['path'])); |
| 748 | 748 | |
| 749 | - if(!isset($file['size'])) |
|
| 749 | + if (!isset($file['size'])) |
|
| 750 | 750 | $file['size'] = 0; |
| 751 | - if(!isset($file['visibility'])) |
|
| 751 | + if (!isset($file['visibility'])) |
|
| 752 | 752 | $file['visibility'] = "private"; |
| 753 | 753 | |
| 754 | 754 | $line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL; |
| 755 | 755 | |
| 756 | 756 | $this->last_logged_file = $file['path']; |
| 757 | 757 | |
| 758 | - try{ |
|
| 758 | + try { |
|
| 759 | 759 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
| 760 | 760 | |
| 761 | - }catch(Exception $e){ |
|
| 761 | + }catch (Exception $e) { |
|
| 762 | 762 | |
| 763 | 763 | $this->logger->error($e->getMessage()); |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if($file['type'] == "dir"){ |
|
| 767 | - try{ |
|
| 766 | + if ($file['type'] == "dir") { |
|
| 767 | + try { |
|
| 768 | 768 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
| 769 | - }catch(Exception $e){ |
|
| 769 | + }catch (Exception $e) { |
|
| 770 | 770 | $this->logger->error($e->getMessage()); |
| 771 | 771 | } |
| 772 | 772 | } |
@@ -779,13 +779,13 @@ discard block |
||
| 779 | 779 | |
| 780 | 780 | public function get_filesystem($system = "") |
| 781 | 781 | { |
| 782 | - if($system == "storage_filesystem_append") |
|
| 782 | + if ($system == "storage_filesystem_append") |
|
| 783 | 783 | return $this->storage_filesystem_append; |
| 784 | - elseif($system == "tmp_filesystem_append") |
|
| 784 | + elseif ($system == "tmp_filesystem_append") |
|
| 785 | 785 | return $this->tmp_filesystem_append; |
| 786 | - elseif($system == "tmp_filesystem") |
|
| 786 | + elseif ($system == "tmp_filesystem") |
|
| 787 | 787 | return $this->tmp_filesystem; |
| 788 | - elseif($system == "storage_filesystem") |
|
| 788 | + elseif ($system == "storage_filesystem") |
|
| 789 | 789 | return $this->storage_filesystem; |
| 790 | 790 | else |
| 791 | 791 | return $this->start_filesystem; |
@@ -793,9 +793,9 @@ discard block |
||
| 793 | 793 | |
| 794 | 794 | public function get_adapter($system) |
| 795 | 795 | { |
| 796 | - if($system == "tmp_filesystem") |
|
| 796 | + if ($system == "tmp_filesystem") |
|
| 797 | 797 | return $this->tmp_adapter; |
| 798 | - elseif($system == "storage_filesystem") |
|
| 798 | + elseif ($system == "storage_filesystem") |
|
| 799 | 799 | return $this->storage_adapter; |
| 800 | 800 | else |
| 801 | 801 | return $this->start_adapter; |
@@ -803,10 +803,10 @@ discard block |
||
| 803 | 803 | |
| 804 | 804 | private function scan_finished() |
| 805 | 805 | { |
| 806 | - if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 806 | + if ($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 807 | 807 | return false; |
| 808 | 808 | |
| 809 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 809 | + if ($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 810 | 810 | $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
| 811 | 811 | |
| 812 | 812 | $this->logger->debug(sprintf(("File scan finished"))); |
@@ -816,7 +816,7 @@ discard block |
||
| 816 | 816 | |
| 817 | 817 | private function calc_to_bytes($mb_size) |
| 818 | 818 | { |
| 819 | - return $mb_size*(1024*1024); |
|
| 819 | + return $mb_size * (1024 * 1024); |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | } |
@@ -59,13 +59,14 @@ discard block |
||
| 59 | 59 | $this->storage_filesystem_append = new Filesystem($this->storage_adapter, new Config([ |
| 60 | 60 | 'disable_asserts' => true, |
| 61 | 61 | ])); |
| 62 | - }catch(Exception $e){ |
|
| 62 | + } catch(Exception $e){ |
|
| 63 | 63 | return false; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - if($value = get_option('xcloner_directories_to_scan_per_request')) |
|
| 68 | - $this->folders_to_process_per_session = $value; |
|
| 67 | + if($value = get_option('xcloner_directories_to_scan_per_request')) { |
|
| 68 | + $this->folders_to_process_per_session = $value; |
|
| 69 | + } |
|
| 69 | 70 | |
| 70 | 71 | } |
| 71 | 72 | |
@@ -128,8 +129,9 @@ discard block |
||
| 128 | 129 | public function get_included_files_handler($metadata = 0) |
| 129 | 130 | { |
| 130 | 131 | $path = $this->included_files_handler; |
| 131 | - if(!$metadata) |
|
| 132 | - return $path; |
|
| 132 | + if(!$metadata) { |
|
| 133 | + return $path; |
|
| 134 | + } |
|
| 133 | 135 | |
| 134 | 136 | $spl_info = $this->getMetadataFull('tmp_adapter', $path); |
| 135 | 137 | return $spl_info; |
@@ -145,31 +147,36 @@ discard block |
||
| 145 | 147 | { |
| 146 | 148 | $files = $this->get_backup_archives_list(); |
| 147 | 149 | |
| 148 | - if(is_array($files)) |
|
| 149 | - $this->sort_by($files, "timestamp","desc"); |
|
| 150 | + if(is_array($files)) { |
|
| 151 | + $this->sort_by($files, "timestamp","desc"); |
|
| 152 | + } |
|
| 150 | 153 | |
| 151 | 154 | $new_list = array(); |
| 152 | 155 | |
| 153 | - foreach($files as $key=>$file) |
|
| 154 | - if(!isset($file['parent'])) |
|
| 156 | + foreach($files as $key=>$file) { |
|
| 157 | + if(!isset($file['parent'])) |
|
| 155 | 158 | $new_list[] = ($files[$key]); |
| 159 | + } |
|
| 156 | 160 | |
| 157 | - if(isset($new_list[0])) |
|
| 158 | - return $new_list[0]; |
|
| 161 | + if(isset($new_list[0])) { |
|
| 162 | + return $new_list[0]; |
|
| 163 | + } |
|
| 159 | 164 | } |
| 160 | 165 | |
| 161 | 166 | public function get_latest_backups() |
| 162 | 167 | { |
| 163 | 168 | $files = $this->get_backup_archives_list(); |
| 164 | 169 | |
| 165 | - if(is_array($files)) |
|
| 166 | - $this->sort_by($files, "timestamp","desc"); |
|
| 170 | + if(is_array($files)) { |
|
| 171 | + $this->sort_by($files, "timestamp","desc"); |
|
| 172 | + } |
|
| 167 | 173 | |
| 168 | 174 | $new_list = array(); |
| 169 | 175 | |
| 170 | - foreach($files as $key=>$file) |
|
| 171 | - if(!isset($file['parent'])) |
|
| 176 | + foreach($files as $key=>$file) { |
|
| 177 | + if(!isset($file['parent'])) |
|
| 172 | 178 | $new_list[] = ($files[$key]); |
| 179 | + } |
|
| 173 | 180 | |
| 174 | 181 | return $new_list; |
| 175 | 182 | } |
@@ -179,25 +186,28 @@ discard block |
||
| 179 | 186 | $files = $this->get_backup_archives_list(); |
| 180 | 187 | $total = 0; |
| 181 | 188 | |
| 182 | - if(is_array($files)) |
|
| 183 | - foreach($files as $file) |
|
| 189 | + if(is_array($files)) { |
|
| 190 | + foreach($files as $file) |
|
| 184 | 191 | $total += $file['size']; |
| 192 | + } |
|
| 185 | 193 | |
| 186 | 194 | return $total; |
| 187 | 195 | } |
| 188 | 196 | |
| 189 | 197 | public function is_part($backup_name) |
| 190 | 198 | { |
| 191 | - if(stristr($backup_name, "-part")) |
|
| 192 | - return true; |
|
| 199 | + if(stristr($backup_name, "-part")) { |
|
| 200 | + return true; |
|
| 201 | + } |
|
| 193 | 202 | |
| 194 | 203 | return false; |
| 195 | 204 | } |
| 196 | 205 | |
| 197 | 206 | public function is_multipart($backup_name) |
| 198 | 207 | { |
| 199 | - if(stristr($backup_name, "-multipart")) |
|
| 200 | - return true; |
|
| 208 | + if(stristr($backup_name, "-multipart")) { |
|
| 209 | + return true; |
|
| 210 | + } |
|
| 201 | 211 | |
| 202 | 212 | return false; |
| 203 | 213 | } |
@@ -208,8 +218,9 @@ discard block |
||
| 208 | 218 | if($this->is_multipart($backup_name)) |
| 209 | 219 | { |
| 210 | 220 | $backup_parts = $this->get_multipart_files($backup_name); |
| 211 | - foreach($backup_parts as $part_file) |
|
| 212 | - $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
| 221 | + foreach($backup_parts as $part_file) { |
|
| 222 | + $backup_size += $this->get_storage_filesystem()->getSize($part_file); |
|
| 223 | + } |
|
| 213 | 224 | } |
| 214 | 225 | |
| 215 | 226 | return $backup_size; |
@@ -250,10 +261,11 @@ discard block |
||
| 250 | 261 | } |
| 251 | 262 | } |
| 252 | 263 | |
| 253 | - if($this->get_storage_filesystem()->delete($backup_name)) |
|
| 254 | - $return = true; |
|
| 255 | - else |
|
| 256 | - $return = false; |
|
| 264 | + if($this->get_storage_filesystem()->delete($backup_name)) { |
|
| 265 | + $return = true; |
|
| 266 | + } else { |
|
| 267 | + $return = false; |
|
| 268 | + } |
|
| 257 | 269 | |
| 258 | 270 | return $return; |
| 259 | 271 | } |
@@ -271,8 +283,9 @@ discard block |
||
| 271 | 283 | { |
| 272 | 284 | $list = array(); |
| 273 | 285 | |
| 274 | - if(method_exists($this->get_storage_filesystem(), "listContents")) |
|
| 275 | - $list = $this->get_storage_filesystem()->listContents(); |
|
| 286 | + if(method_exists($this->get_storage_filesystem(), "listContents")) { |
|
| 287 | + $list = $this->get_storage_filesystem()->listContents(); |
|
| 288 | + } |
|
| 276 | 289 | |
| 277 | 290 | |
| 278 | 291 | $backup_files = array(); |
@@ -285,10 +298,11 @@ discard block |
||
| 285 | 298 | if(isset($file_info['extension']) and $file_info['extension'] == "csv") |
| 286 | 299 | { |
| 287 | 300 | $lines = explode(PHP_EOL, $this->get_storage_filesystem()->read($file_info['path'])); |
| 288 | - foreach($lines as $line) |
|
| 289 | - if($line) |
|
| 301 | + foreach($lines as $line) { |
|
| 302 | + if($line) |
|
| 290 | 303 | { |
| 291 | 304 | $data = str_getcsv($line); |
| 305 | + } |
|
| 292 | 306 | if(is_array($data)){ |
| 293 | 307 | $parents[$data[0]] = $file_info['path']; |
| 294 | 308 | $file_info['childs'][] = $data; |
@@ -298,14 +312,16 @@ discard block |
||
| 298 | 312 | |
| 299 | 313 | } |
| 300 | 314 | |
| 301 | - if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) |
|
| 302 | - $backup_files[$file_info['path']] = $file_info; |
|
| 315 | + if($file_info['type'] == 'file' and isset($file_info['extension']) and in_array($file_info['extension'], $this->backup_archive_extensions)) { |
|
| 316 | + $backup_files[$file_info['path']] = $file_info; |
|
| 317 | + } |
|
| 303 | 318 | } |
| 304 | 319 | |
| 305 | 320 | foreach($backup_files as $key=>$file_info) |
| 306 | 321 | { |
| 307 | - if(isset($parents[$file_info['path']])) |
|
| 308 | - $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
| 322 | + if(isset($parents[$file_info['path']])) { |
|
| 323 | + $backup_files[$key]['parent'] = $parents[$file_info['path']]; |
|
| 324 | + } |
|
| 309 | 325 | } |
| 310 | 326 | |
| 311 | 327 | return $backup_files; |
@@ -331,11 +347,11 @@ discard block |
||
| 331 | 347 | if($counter < $this->folders_to_process_per_session){ |
| 332 | 348 | $this->build_files_list($file); |
| 333 | 349 | $counter++; |
| 334 | - }else{ |
|
| 350 | + } else{ |
|
| 335 | 351 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file."\n"); |
| 336 | 352 | } |
| 337 | 353 | } |
| 338 | - }else{ |
|
| 354 | + } else{ |
|
| 339 | 355 | $this->build_files_list(); |
| 340 | 356 | } |
| 341 | 357 | |
@@ -377,8 +393,9 @@ discard block |
||
| 377 | 393 | { |
| 378 | 394 | $return = array(); |
| 379 | 395 | $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->get_included_files_handler(); |
| 380 | - if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) |
|
| 381 | - $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
| 396 | + if($this->xcloner_settings->get_xcloner_option('xcloner_enable_log')) { |
|
| 397 | + $return[] = $this->xcloner_settings->get_xcloner_tmp_path().DS.$this->xcloner_settings->get_logger_filename(1); |
|
| 398 | + } |
|
| 382 | 399 | |
| 383 | 400 | return $return; |
| 384 | 401 | } |
@@ -390,9 +407,10 @@ discard block |
||
| 390 | 407 | |
| 391 | 408 | $contents = $this->get_tmp_filesystem()->listContents(); |
| 392 | 409 | |
| 393 | - if(is_array($contents)) |
|
| 394 | - foreach($contents as $file_info) |
|
| 410 | + if(is_array($contents)) { |
|
| 411 | + foreach($contents as $file_info) |
|
| 395 | 412 | $this->get_tmp_filesystem()->delete($file_info['path']); |
| 413 | + } |
|
| 396 | 414 | |
| 397 | 415 | @rmdir($this->xcloner_settings->get_xcloner_tmp_path()); |
| 398 | 416 | |
@@ -403,17 +421,21 @@ discard block |
||
| 403 | 421 | { |
| 404 | 422 | $this->files_counter = 0; |
| 405 | 423 | |
| 406 | - if(!$this->storage_filesystem->has("index.html")) |
|
| 407 | - $this->storage_filesystem->write("index.html",""); |
|
| 424 | + if(!$this->storage_filesystem->has("index.html")) { |
|
| 425 | + $this->storage_filesystem->write("index.html",""); |
|
| 426 | + } |
|
| 408 | 427 | |
| 409 | - if(!$this->tmp_filesystem->has("index.html")) |
|
| 410 | - $this->tmp_filesystem->write("index.html",""); |
|
| 428 | + if(!$this->tmp_filesystem->has("index.html")) { |
|
| 429 | + $this->tmp_filesystem->write("index.html",""); |
|
| 430 | + } |
|
| 411 | 431 | |
| 412 | - if($this->tmp_filesystem->has($this->get_included_files_handler())) |
|
| 413 | - $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
| 432 | + if($this->tmp_filesystem->has($this->get_included_files_handler())) { |
|
| 433 | + $this->tmp_filesystem->delete($this->get_included_files_handler()); |
|
| 434 | + } |
|
| 414 | 435 | |
| 415 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 416 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 436 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 437 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 438 | + } |
|
| 417 | 439 | } |
| 418 | 440 | |
| 419 | 441 | public function get_scanned_files_num() |
@@ -433,8 +455,9 @@ discard block |
||
| 433 | 455 | |
| 434 | 456 | public function set_excluded_files($excluded_files = array()) |
| 435 | 457 | { |
| 436 | - if(!is_array($excluded_files)) |
|
| 437 | - $excluded_files = array(); |
|
| 458 | + if(!is_array($excluded_files)) { |
|
| 459 | + $excluded_files = array(); |
|
| 460 | + } |
|
| 438 | 461 | |
| 439 | 462 | $this->excluded_files = array_merge($excluded_files, $this->excluded_files_by_default); |
| 440 | 463 | |
@@ -468,21 +491,21 @@ discard block |
||
| 468 | 491 | if(!is_readable($this->xcloner_settings->get_xcloner_start_path().DS.$file['path'])) |
| 469 | 492 | { |
| 470 | 493 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, file not readable"), $file['path']), array("FILESYSTEM SCAN","NOT READABLE")); |
| 471 | - } |
|
| 472 | - elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 494 | + } elseif(!$matching_pattern = $this->is_excluded($file) ){ |
|
| 473 | 495 | $this->logger->info(sprintf(__("Adding %s to the filesystem list"), $file['path']), array("FILESYSTEM SCAN","INCLUDE")); |
| 474 | 496 | $file['visibility'] = $this->start_filesystem->getVisibility($file['path']); |
| 475 | 497 | $this->store_file($file); |
| 476 | 498 | $this->files_counter++; |
| 477 | - if(isset($file['size'])) |
|
| 478 | - $this->files_size += $file['size']; |
|
| 499 | + if(isset($file['size'])) { |
|
| 500 | + $this->files_size += $file['size']; |
|
| 501 | + } |
|
| 479 | 502 | |
| 480 | - }else{ |
|
| 503 | + } else{ |
|
| 481 | 504 | $this->logger->info(sprintf(__("Excluding %s from the filesystem list, matching pattern %s"), $file['path'], $matching_pattern), array("FILESYSTEM SCAN","EXCLUDE")); |
| 482 | 505 | } |
| 483 | 506 | } |
| 484 | 507 | |
| 485 | - }catch(Exception $e){ |
|
| 508 | + } catch(Exception $e){ |
|
| 486 | 509 | |
| 487 | 510 | $this->logger->error($e->getMessage()); |
| 488 | 511 | |
@@ -509,7 +532,7 @@ discard block |
||
| 509 | 532 | |
| 510 | 533 | $this->tmp_filesystem->delete($tmp_file); |
| 511 | 534 | |
| 512 | - }catch(Exception $e){ |
|
| 535 | + } catch(Exception $e){ |
|
| 513 | 536 | |
| 514 | 537 | $this->logger->error($e->getMessage()); |
| 515 | 538 | |
@@ -530,12 +553,14 @@ discard block |
||
| 530 | 553 | |
| 531 | 554 | $files = $this->storage_filesystem->listContents(); |
| 532 | 555 | |
| 533 | - if(is_array($files)) |
|
| 534 | - foreach($files as $file) |
|
| 556 | + if(is_array($files)) { |
|
| 557 | + foreach($files as $file) |
|
| 535 | 558 | { |
| 536 | 559 | if(isset($file['extension']) and in_array($file['extension'], $this->backup_archive_extensions)) |
| 537 | 560 | { |
| 538 | - $_storage_size += $file['size']; //bytes |
|
| 561 | + $_storage_size += $file['size']; |
|
| 562 | + } |
|
| 563 | + //bytes |
|
| 539 | 564 | $_backup_files_list[] = $file; |
| 540 | 565 | } |
| 541 | 566 | } |
@@ -549,9 +574,11 @@ discard block |
||
| 549 | 574 | { |
| 550 | 575 | //processing rule folder capacity |
| 551 | 576 | if($this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit') && |
| 552 | - $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) //bytes |
|
| 577 | + $_storage_size >= ($set_storage_limit = 1024*1024*$this->xcloner_settings->get_xcloner_option('xcloner_cleanup_capacity_limit'))) { |
|
| 578 | + //bytes |
|
| 553 | 579 | { |
| 554 | 580 | $this->storage_filesystem->delete($file['path']); |
| 581 | + } |
|
| 555 | 582 | $_storage_size -= $file['size']; |
| 556 | 583 | $this->logger->info("Deleting backup ".$file['path']." matching rule", array("STORAGE SIZE LIMIT", $_storage_size." >= ".$set_storage_limit)); |
| 557 | 584 | } |
@@ -592,24 +619,26 @@ discard block |
||
| 592 | 619 | |
| 593 | 620 | public function process_backup_name($name = "", $max_length=100) |
| 594 | 621 | { |
| 595 | - if(!$name) |
|
| 596 | - $name = $this->xcloner_settings->get_default_backup_name(); |
|
| 622 | + if(!$name) { |
|
| 623 | + $name = $this->xcloner_settings->get_default_backup_name(); |
|
| 624 | + } |
|
| 597 | 625 | |
| 598 | 626 | foreach($this->backup_name_tags as $tag) |
| 599 | 627 | { |
| 600 | - if($tag == '[time]') |
|
| 601 | - $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 602 | - elseif($tag == '[hostname]') |
|
| 603 | - $name = str_replace($tag, gethostname() ,$name); |
|
| 604 | - elseif($tag == '[domain]') |
|
| 628 | + if($tag == '[time]') { |
|
| 629 | + $name = str_replace($tag, date("Y-m-d_H-i"),$name); |
|
| 630 | + } elseif($tag == '[hostname]') { |
|
| 631 | + $name = str_replace($tag, gethostname() ,$name); |
|
| 632 | + } elseif($tag == '[domain]') |
|
| 605 | 633 | { |
| 606 | 634 | $domain = parse_url(admin_url(), PHP_URL_HOST); |
| 607 | 635 | $name = str_replace($tag, $domain ,$name); |
| 608 | 636 | } |
| 609 | 637 | } |
| 610 | 638 | |
| 611 | - if($max_length) |
|
| 612 | - $name = substr($name, 0, $max_length); |
|
| 639 | + if($max_length) { |
|
| 640 | + $name = substr($name, 0, $max_length); |
|
| 641 | + } |
|
| 613 | 642 | |
| 614 | 643 | return $name; |
| 615 | 644 | } |
@@ -626,10 +655,11 @@ discard block |
||
| 626 | 655 | return 0; |
| 627 | 656 | } |
| 628 | 657 | |
| 629 | - if(strlower($direction) == 'desc' ) |
|
| 630 | - return ($a > $b) ? -1 : 1; |
|
| 631 | - else |
|
| 632 | - return ($a < $b) ? -1 : 1; |
|
| 658 | + if(strlower($direction) == 'desc' ) { |
|
| 659 | + return ($a > $b) ? -1 : 1; |
|
| 660 | + } else { |
|
| 661 | + return ($a < $b) ? -1 : 1; |
|
| 662 | + } |
|
| 633 | 663 | |
| 634 | 664 | //return ($a ($direction == 'desc' ? '>' : '<') $b) ? -1 : 1; |
| 635 | 665 | } |
@@ -649,28 +679,32 @@ discard block |
||
| 649 | 679 | |
| 650 | 680 | if($xcloner_exclude_files_larger_than_mb = $this->xcloner_settings->get_xcloner_option('xcloner_exclude_files_larger_than_mb')) |
| 651 | 681 | { |
| 652 | - if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) |
|
| 653 | - return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
| 682 | + if(isset($file['size']) and $file['size'] > $this->calc_to_bytes($xcloner_exclude_files_larger_than_mb)) { |
|
| 683 | + return "> ".$xcloner_exclude_files_larger_than_mb."MB"; |
|
| 684 | + } |
|
| 654 | 685 | } |
| 655 | 686 | |
| 656 | - if(!sizeof($this->excluded_files)) |
|
| 657 | - $this->set_excluded_files(); |
|
| 687 | + if(!sizeof($this->excluded_files)) { |
|
| 688 | + $this->set_excluded_files(); |
|
| 689 | + } |
|
| 658 | 690 | |
| 659 | - if(is_array($this->excluded_files)) |
|
| 660 | - foreach($this->excluded_files as $excluded_file_pattern) |
|
| 691 | + if(is_array($this->excluded_files)) { |
|
| 692 | + foreach($this->excluded_files as $excluded_file_pattern) |
|
| 661 | 693 | { |
| 662 | 694 | if($excluded_file_pattern == "/") |
| 663 | 695 | $needle = "$"; |
| 664 | - else |
|
| 665 | - $needle = "$".$excluded_file_pattern; |
|
| 696 | + } else { |
|
| 697 | + $needle = "$".$excluded_file_pattern; |
|
| 698 | + } |
|
| 666 | 699 | |
| 667 | 700 | if(strstr("$".$file['path'], $needle)){ |
| 668 | 701 | return $excluded_file_pattern; |
| 669 | 702 | } |
| 670 | 703 | } |
| 671 | 704 | |
| 672 | - if( $regex = $this->is_excluded_regex($file)) |
|
| 673 | - return $regex; |
|
| 705 | + if( $regex = $this->is_excluded_regex($file)) { |
|
| 706 | + return $regex; |
|
| 707 | + } |
|
| 674 | 708 | |
| 675 | 709 | return false; |
| 676 | 710 | } |
@@ -724,13 +758,15 @@ discard block |
||
| 724 | 758 | foreach($regex_patterns as $excluded_file_pattern) |
| 725 | 759 | { |
| 726 | 760 | |
| 727 | - if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") |
|
| 728 | - $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 761 | + if( substr($excluded_file_pattern, strlen($excluded_file_pattern)-1, strlen($excluded_file_pattern)) == "\r") { |
|
| 762 | + $excluded_file_pattern = substr($excluded_file_pattern, 0, strlen($excluded_file_pattern)-1); |
|
| 763 | + } |
|
| 729 | 764 | |
| 730 | - if($file['path'] == "/") |
|
| 731 | - $needle = "/"; |
|
| 732 | - else |
|
| 733 | - $needle = "/".$file['path']; |
|
| 765 | + if($file['path'] == "/") { |
|
| 766 | + $needle = "/"; |
|
| 767 | + } else { |
|
| 768 | + $needle = "/".$file['path']; |
|
| 769 | + } |
|
| 734 | 770 | //echo $needle."---".$excluded_file_pattern."---\n"; |
| 735 | 771 | |
| 736 | 772 | if(@preg_match("/(^|^\/)".$excluded_file_pattern."/i", $needle)){ |
@@ -746,10 +782,12 @@ discard block |
||
| 746 | 782 | { |
| 747 | 783 | $this->logger->debug(sprintf("Storing %s in the backup list", $file['path'])); |
| 748 | 784 | |
| 749 | - if(!isset($file['size'])) |
|
| 750 | - $file['size'] = 0; |
|
| 751 | - if(!isset($file['visibility'])) |
|
| 752 | - $file['visibility'] = "private"; |
|
| 785 | + if(!isset($file['size'])) { |
|
| 786 | + $file['size'] = 0; |
|
| 787 | + } |
|
| 788 | + if(!isset($file['visibility'])) { |
|
| 789 | + $file['visibility'] = "private"; |
|
| 790 | + } |
|
| 753 | 791 | |
| 754 | 792 | $line = '"'.addslashes($file['path']).'","'.$file['timestamp'].'","'.$file['size'].'","'.$file['visibility'].'","'.$storage.'"'.PHP_EOL; |
| 755 | 793 | |
@@ -758,7 +796,7 @@ discard block |
||
| 758 | 796 | try{ |
| 759 | 797 | $this->tmp_filesystem_append->write($this->get_included_files_handler(), $line); |
| 760 | 798 | |
| 761 | - }catch(Exception $e){ |
|
| 799 | + } catch(Exception $e){ |
|
| 762 | 800 | |
| 763 | 801 | $this->logger->error($e->getMessage()); |
| 764 | 802 | } |
@@ -766,7 +804,7 @@ discard block |
||
| 766 | 804 | if($file['type'] == "dir"){ |
| 767 | 805 | try{ |
| 768 | 806 | $this->tmp_filesystem_append->write($this->get_temp_dir_handler(), $file['path']."\n"); |
| 769 | - }catch(Exception $e){ |
|
| 807 | + } catch(Exception $e){ |
|
| 770 | 808 | $this->logger->error($e->getMessage()); |
| 771 | 809 | } |
| 772 | 810 | } |
@@ -779,35 +817,39 @@ discard block |
||
| 779 | 817 | |
| 780 | 818 | public function get_filesystem($system = "") |
| 781 | 819 | { |
| 782 | - if($system == "storage_filesystem_append") |
|
| 783 | - return $this->storage_filesystem_append; |
|
| 784 | - elseif($system == "tmp_filesystem_append") |
|
| 785 | - return $this->tmp_filesystem_append; |
|
| 786 | - elseif($system == "tmp_filesystem") |
|
| 787 | - return $this->tmp_filesystem; |
|
| 788 | - elseif($system == "storage_filesystem") |
|
| 789 | - return $this->storage_filesystem; |
|
| 790 | - else |
|
| 791 | - return $this->start_filesystem; |
|
| 820 | + if($system == "storage_filesystem_append") { |
|
| 821 | + return $this->storage_filesystem_append; |
|
| 822 | + } elseif($system == "tmp_filesystem_append") { |
|
| 823 | + return $this->tmp_filesystem_append; |
|
| 824 | + } elseif($system == "tmp_filesystem") { |
|
| 825 | + return $this->tmp_filesystem; |
|
| 826 | + } elseif($system == "storage_filesystem") { |
|
| 827 | + return $this->storage_filesystem; |
|
| 828 | + } else { |
|
| 829 | + return $this->start_filesystem; |
|
| 830 | + } |
|
| 792 | 831 | } |
| 793 | 832 | |
| 794 | 833 | public function get_adapter($system) |
| 795 | 834 | { |
| 796 | - if($system == "tmp_filesystem") |
|
| 797 | - return $this->tmp_adapter; |
|
| 798 | - elseif($system == "storage_filesystem") |
|
| 799 | - return $this->storage_adapter; |
|
| 800 | - else |
|
| 801 | - return $this->start_adapter; |
|
| 835 | + if($system == "tmp_filesystem") { |
|
| 836 | + return $this->tmp_adapter; |
|
| 837 | + } elseif($system == "storage_filesystem") { |
|
| 838 | + return $this->storage_adapter; |
|
| 839 | + } else { |
|
| 840 | + return $this->start_adapter; |
|
| 841 | + } |
|
| 802 | 842 | } |
| 803 | 843 | |
| 804 | 844 | private function scan_finished() |
| 805 | 845 | { |
| 806 | - if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) |
|
| 807 | - return false; |
|
| 846 | + if($this->tmp_filesystem_append->has($this->get_temp_dir_handler()) && $this->tmp_filesystem_append->getSize($this->get_temp_dir_handler())) { |
|
| 847 | + return false; |
|
| 848 | + } |
|
| 808 | 849 | |
| 809 | - if($this->tmp_filesystem->has($this->get_temp_dir_handler())) |
|
| 810 | - $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 850 | + if($this->tmp_filesystem->has($this->get_temp_dir_handler())) { |
|
| 851 | + $this->tmp_filesystem->delete($this->get_temp_dir_handler()); |
|
| 852 | + } |
|
| 811 | 853 | |
| 812 | 854 | $this->logger->debug(sprintf(("File scan finished"))); |
| 813 | 855 | |