Check if data variable in scanner isn't null before using it

This commit is contained in:
Michael Gapczynski 2012-11-24 20:29:57 -05:00
parent 709aacfa0f
commit cc5d8e5609
1 changed files with 23 additions and 19 deletions

View File

@ -70,17 +70,19 @@ class Scanner {
public function scanFile($file) { public function scanFile($file) {
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId)); \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId));
$data = $this->getData($file); $data = $this->getData($file);
if ($file !== '') { if ($data) {
$parent = dirname($file); if ($file !== '') {
if ($parent === '.') { $parent = dirname($file);
$parent = ''; if ($parent === '.') {
} $parent = '';
if (!$this->cache->inCache($parent)) { }
$this->scanFile($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; return $data;
} }
@ -101,17 +103,19 @@ class Scanner {
if ($file !== '.' and $file !== '..') { if ($file !== '.' and $file !== '..') {
$child = ($path !== '') ? $path . '/' . $file : $file; $child = ($path !== '') ? $path . '/' . $file : $file;
$data = $this->scanFile($child); $data = $this->scanFile($child);
if ($data['mimetype'] === 'httpd/unix-directory') { if ($data) {
if ($recursive === self::SCAN_RECURSIVE) { if ($data['mimetype'] === 'httpd/unix-directory') {
$data['size'] = $this->scan($child, self::SCAN_RECURSIVE); if ($recursive === self::SCAN_RECURSIVE) {
} else { $data['size'] = $this->scan($child, self::SCAN_RECURSIVE);
$data['size'] = -1; } 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'];
} }
} }
} }