Only update metadata that has changed

This commit is contained in:
Michael Gapczynski 2013-05-29 10:19:03 -04:00
parent fee43ec506
commit 04805d0be9

View file

@ -78,7 +78,7 @@ class Scanner {
$this->scanFile($parent);
}
}
if($cacheData = $this->cache->get($file)) {
if ($cacheData = $this->cache->get($file)) {
if ($data['mtime'] === $cacheData['mtime'] &&
$data['size'] === $cacheData['size']) {
$data['etag'] = $cacheData['etag'];
@ -89,7 +89,14 @@ class Scanner {
$data['size'] = $cacheData['size'];
}
}
$this->cache->put($file, $data);
$newData = $data;
if ($cacheData) {
// Only update metadata that has changed
$newData = array_diff($data, $cacheData);
}
if (!empty($newData)) {
$this->cache->put($file, $newData);
}
}
return $data;
}