aboutsummaryrefslogtreecommitdiffstats
path: root/lib/files/cache
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2013-09-04 13:06:04 +0200
committerArthur Schiwon <blizzz@owncloud.com>2013-09-04 13:06:04 +0200
commitec3639dc7a28348b136d2008e692cffe8c3753ad (patch)
tree3d197d325496925be0ddee1f1ab22c48c7c817a1 /lib/files/cache
parent09187f3b3b30e6f810c6afff7332615ed472154e (diff)
downloadnextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.tar.gz
nextcloud-server-ec3639dc7a28348b136d2008e692cffe8c3753ad.zip
Always check variable type before using readdir to avoid surprises
Diffstat (limited to 'lib/files/cache')
-rw-r--r--lib/files/cache/scanner.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php
index 87fa7c1365a..9d180820e9d 100644
--- a/lib/files/cache/scanner.php
+++ b/lib/files/cache/scanner.php
@@ -159,20 +159,22 @@ class Scanner extends BasicEmitter {
$newChildren = array();
if ($this->storage->is_dir($path) && ($dh = $this->storage->opendir($path))) {
\OC_DB::beginTransaction();
- while (($file = readdir($dh)) !== false) {
- $child = ($path) ? $path . '/' . $file : $file;
- if (!Filesystem::isIgnoredDir($file)) {
- $newChildren[] = $file;
- $data = $this->scanFile($child, $reuse, true);
- if ($data) {
- if ($data['size'] === -1) {
- if ($recursive === self::SCAN_RECURSIVE) {
- $childQueue[] = $child;
- } else {
- $size = -1;
+ if(is_resource($dh)) {
+ while (($file = readdir($dh)) !== false) {
+ $child = ($path) ? $path . '/' . $file : $file;
+ if (!Filesystem::isIgnoredDir($file)) {
+ $newChildren[] = $file;
+ $data = $this->scanFile($child, $reuse, true);
+ if ($data) {
+ if ($data['size'] === -1) {
+ if ($recursive === self::SCAN_RECURSIVE) {
+ $childQueue[] = $child;
+ } else {
+ $size = -1;
+ }
+ } else if ($size !== -1) {
+ $size += $data['size'];
}
- } else if ($size !== -1) {
- $size += $data['size'];
}
}
}