Skip to content

Commit

Permalink
Properly reset the checksum if the file data has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jvillafanez committed Aug 13, 2018
1 parent 0f712a1 commit 9f0131d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apps/files/tests/Command/VerifyChecksumsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ private function refreshFileInfo(File &$f) {

private function assertChecksumsAreCorrect(array $files) {
foreach ($files as $key => $file) {
/** @var File $f */
$f = $files[$key]['file'];
$expectedChecksums = $files[$key]['expectedChecksums'];
$this->refreshFileInfo($files[$key]['file']);
/** @var File $f */
$f = $files[$key]['file'];
$this->assertSame(
$expectedChecksums(),
$f->getChecksum()
Expand Down
9 changes: 6 additions & 3 deletions lib/private/Files/Cache/Scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,12 @@ public function scanFile($file, $reuseExisting = 0, $parentId = -1, $cacheData =
}
if (!empty($newData)) {
// Only reset checksum on file change
foreach (\array_intersect_key($newData, $data) as $key => $value) {
if (\in_array($key, ['size', 'storage_mtime', 'mtime', 'etag']) && $data[$key] != $newData[$key]) {
$newData['checksum'] = '';
if ($fileId > 0 && !isset($newData['checksum'])) {
foreach (['size', 'storage_mtime', 'mtime', 'etag'] as $dataKey) {
if (isset($newData[$dataKey])) {
$newData['checksum'] = '';
break;
}
}
}

Expand Down

0 comments on commit 9f0131d

Please sign in to comment.