summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/files/cache/scanner.php2
-rw-r--r--tests/lib/files/view.php20
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 5ca32548fe0..c16e8515b01 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -195,6 +195,8 @@ class Scanner extends BasicEmitter implements IScanner {
$fileId = -1;
}
if (!empty($newData)) {
+ // Reset the checksum if the data has changed
+ $newData['checksum'] = '';
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
}
if (isset($cacheData['size'])) {
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 3e88a5306f8..86413c61aa1 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -2424,4 +2424,24 @@ class View extends \Test\TestCase {
$this->assertEquals($expected, $files);
}
+
+ public function testFilePutContentsClearsChecksum() {
+ $storage = new Temporary(array());
+ $scanner = $storage->getScanner();
+ $storage->file_put_contents('foo.txt', 'bar');
+ \OC\Files\Filesystem::mount($storage, array(), '/test/');
+ $scanner->scan('');
+
+ $view = new \OC\Files\View('/test/foo.txt');
+ $view->putFileInfo('.', ['checksum' => '42']);
+
+ $this->assertEquals('bar', $view->file_get_contents(''));
+ $fh = tmpfile();
+ fwrite($fh, 'fooo');
+ rewind($fh);
+ $view->file_put_contents('', $fh);
+ $this->assertEquals('fooo', $view->file_get_contents(''));
+ $data = $view->getFileInfo('.');
+ $this->assertEquals('', $data->getChecksum());
+ }
}