Check if fields we need are actually set to prevent errors

This commit is contained in:
Robin Appelman 2014-03-03 16:48:28 +01:00
parent bb8a7a2230
commit 06c6163265
2 changed files with 3 additions and 3 deletions

View File

@ -520,7 +520,7 @@ class Cache {
*/ */
public function calculateFolderSize($path, $entry = null) { public function calculateFolderSize($path, $entry = null) {
$totalSize = 0; $totalSize = 0;
if (is_null($entry)) { if (is_null($entry) or !isset($entry['fileid'])) {
$entry = $this->get($path); $entry = $this->get($path);
} }
if ($entry && $entry['mimetype'] === 'httpd/unix-directory') { if ($entry && $entry['mimetype'] === 'httpd/unix-directory') {
@ -544,7 +544,7 @@ class Cache {
if ($entry['size'] !== $totalSize) { if ($entry['size'] !== $totalSize) {
$update['size'] = $totalSize; $update['size'] = $totalSize;
} }
if ($entry['unencrypted_size'] !== $unencryptedSum) { if (!isset($entry['unencrypted_size']) or $entry['unencrypted_size'] !== $unencryptedSum) {
$update['unencrypted_size'] = $unencryptedSum; $update['unencrypted_size'] = $unencryptedSum;
} }
if (count($update) > 0) { if (count($update) > 0) {

View File

@ -155,7 +155,7 @@ class Scanner extends BasicEmitter {
} }
} }
if (!empty($newData)) { if (!empty($newData)) {
$this->cache->put($file, $newData); $data['fileid'] = $this->cache->put($file, $newData);
$this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId)); $this->emit('\OC\Files\Cache\Scanner', 'postScanFile', array($file, $this->storageId));
\OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId)); \OC_Hook::emit('\OC\Files\Cache\Scanner', 'post_scan_file', array('path' => $file, 'storage' => $this->storageId));
} }