diff options
author | Michael Gapczynski <mtgap@owncloud.com> | 2012-11-24 20:29:57 -0500 |
---|---|---|
committer | Michael Gapczynski <mtgap@owncloud.com> | 2012-11-24 20:29:57 -0500 |
commit | cc5d8e56098189f49fbd68c598c11be2b8354846 (patch) | |
tree | 558fe1e8870d1de84491f953c6f2feee4dcbf3ca /lib | |
parent | 709aacfa0fef29692bff231f09625db5ba0bef6f (diff) | |
download | nextcloud-server-cc5d8e56098189f49fbd68c598c11be2b8354846.tar.gz nextcloud-server-cc5d8e56098189f49fbd68c598c11be2b8354846.zip |
Check if data variable in scanner isn't null before using it
Diffstat (limited to 'lib')
-rw-r--r-- | lib/files/cache/scanner.php | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 3c83b6528a7..9ee509bb132 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -70,17 +70,19 @@ class Scanner { public function scanFile($file) { \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId)); $data = $this->getData($file); - if ($file !== '') { - $parent = dirname($file); - if ($parent === '.') { - $parent = ''; - } - if (!$this->cache->inCache($parent)) { - $this->scanFile($parent); + if ($data) { + if ($file !== '') { + $parent = dirname($file); + if ($parent === '.') { + $parent = ''; + } + if (!$this->cache->inCache($parent)) { + $this->scanFile($parent); + } } + $id = $this->cache->put($file, $data); + $this->permissionsCache->set($id, \OC_User::getUser(), $data['permissions']); } - $id = $this->cache->put($file, $data); - $this->permissionsCache->set($id, \OC_User::getUser(), $data['permissions']); return $data; } @@ -101,17 +103,19 @@ class Scanner { if ($file !== '.' and $file !== '..') { $child = ($path !== '') ? $path . '/' . $file : $file; $data = $this->scanFile($child); - if ($data['mimetype'] === 'httpd/unix-directory') { - if ($recursive === self::SCAN_RECURSIVE) { - $data['size'] = $this->scan($child, self::SCAN_RECURSIVE); - } else { - $data['size'] = -1; + if ($data) { + if ($data['mimetype'] === 'httpd/unix-directory') { + if ($recursive === self::SCAN_RECURSIVE) { + $data['size'] = $this->scan($child, self::SCAN_RECURSIVE); + } else { + $data['size'] = -1; + } + } + if ($data['size'] === -1) { + $size = -1; + } elseif ($size !== -1) { + $size += $data['size']; } - } - if ($data['size'] === -1) { - $size = -1; - } elseif ($size !== -1) { - $size += $data['size']; } } } |