Skip to content
Snippets Groups Projects
Commit 21299745 authored by Andreas Fischer's avatar Andreas Fischer
Browse files

Do not recheck $cacheData. Move if($reuseExisting) under if($cacheData).

parent 235517f1
No related branches found
No related tags found
No related merge requests found
......@@ -105,39 +105,39 @@ class Scanner extends BasicEmitter {
$cacheData = $this->cache->get($file);
if ($cacheData) {
$this->permissionsCache->remove($cacheData['fileid']);
}
if ($reuseExisting and $cacheData) {
// prevent empty etag
$etag = $cacheData['etag'];
$propagateETagChange = false;
if (empty($etag)) {
$etag = $data['etag'];
$propagateETagChange = true;
}
// only reuse data if the file hasn't explicitly changed
if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
if ($reuseExisting) {
// prevent empty etag
$etag = $cacheData['etag'];
$propagateETagChange = false;
if (empty($etag)) {
$etag = $data['etag'];
$propagateETagChange = true;
}
if ($reuseExisting & self::REUSE_ETAG) {
$data['etag'] = $etag;
if ($propagateETagChange) {
$parent = $file;
while ($parent !== '') {
$parent = dirname($parent);
if ($parent === '.') {
$parent = '';
// only reuse data if the file hasn't explicitly changed
if (isset($data['mtime']) && isset($cacheData['mtime']) && $data['mtime'] === $cacheData['mtime']) {
if (($reuseExisting & self::REUSE_SIZE) && ($data['size'] === -1)) {
$data['size'] = $cacheData['size'];
}
if ($reuseExisting & self::REUSE_ETAG) {
$data['etag'] = $etag;
if ($propagateETagChange) {
$parent = $file;
while ($parent !== '') {
$parent = dirname($parent);
if ($parent === '.') {
$parent = '';
}
$parentCacheData = $this->cache->get($parent);
$this->cache->update($parentCacheData['fileid'], array(
'etag' => $this->storage->getETag($parent),
));
}
$parentCacheData = $this->cache->get($parent);
$this->cache->update($parentCacheData['fileid'], array(
'etag' => $this->storage->getETag($parent),
));
}
}
}
// Only update metadata that has changed
$newData = array_diff($data, $cacheData);
}
// Only update metadata that has changed
$newData = array_diff($data, $cacheData);
}
if (!empty($newData)) {
$this->cache->put($file, $newData);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment