Skip to content

Commit

Permalink
Explicitly close the directory stream
Browse files Browse the repository at this point in the history
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
  • Loading branch information
solracsf authored Oct 20, 2023
1 parent e49353d commit 6f238e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/private/Cache/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,15 @@ public function remove($key) {
*/
public function clear($prefix = '') {
$storage = $this->getStorage();
if ($storage and $storage->is_dir('/')) {
if ($storage && $storage->is_dir('/')) {
$dh = $storage->opendir('/');
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' and $file != '..' and ($prefix === '' || str_starts_with($file, $prefix))) {
if ($file != '.' && $file != '..' && ($prefix === '' || str_starts_with($file, $prefix))) {
$storage->unlink('/' . $file);
}
}
closedir($dh);
}
}
return true;
Expand All @@ -184,7 +185,7 @@ public function gc() {
return null;
}
while (($file = readdir($dh)) !== false) {
if ($file != '.' and $file != '..') {
if ($file != '.' && $file != '..') {
try {
$mtime = $storage->filemtime('/' . $file);
if ($mtime < $now) {
Expand All @@ -200,6 +201,7 @@ public function gc() {
}
}
}
closedir($dh);
}
}

Expand Down

0 comments on commit 6f238e7

Please sign in to comment.