1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-14 10:45:54 +02:00

Updates per processwire/processwire-issues#704 with WireTempDir log entries

This commit is contained in:
Ryan Cramer
2018-11-29 11:12:11 -05:00
parent cc212b3254
commit fcc353bc3c
2 changed files with 6 additions and 3 deletions

View File

@@ -104,7 +104,7 @@ class WireFileTools extends Wire {
$files = @scandir($path);
if(is_array($files)) foreach($files as $file) {
if($file == '.' || $file == '..' || strpos($file, '..') !== false) continue;
$pathname = "$path/$file";
$pathname = rtrim($path, '/') . '/' . $file;
if(is_dir($pathname)) {
$this->rmdir($pathname, $recursive, $options);
} else {

View File

@@ -276,7 +276,7 @@ class WireTempDir extends Wire {
}
}
if(!$numSubdirs) {
if(!$numSubdirs && $path != $this->classRoot && $this->isTempDir($path)) {
// if no subdirectories, we can remove the root
if($this->rmdir($path, true)) {
$success = true;
@@ -381,10 +381,13 @@ class WireTempDir extends Wire {
*
*/
protected function isTempDir($dir) {
$files = $this->wire('files');
if(!strlen($dir) || !is_dir($dir)) {
// if given a non-directory return false
return false;
} else if($this->classRoot && $this->wire('files')->fileInPath($dir, $this->classRoot)) {
}
if($this->classRoot && $files->fileInPath($dir, $this->classRoot)) {
// dir is within classRoot path
return true;
}
return false;