diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-20 20:37:01 +0200 |
---|---|---|
committer | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-04-20 20:37:01 +0200 |
commit | cdcabbd0b3f6209b2a312b30a84c381f125bcf68 (patch) | |
tree | b7542987656a5d91f785f4a0570fb3c07ace9df5 | |
parent | 01b09b4f92f7a73873875b29ad11d39415adfa77 (diff) | |
parent | 0dbcbc4cae2eb669fc73f60a761855a907469111 (diff) | |
download | nextcloud-server-cdcabbd0b3f6209b2a312b30a84c381f125bcf68.tar.gz nextcloud-server-cdcabbd0b3f6209b2a312b30a84c381f125bcf68.zip |
Merge pull request #24098 from owncloud/fix_23782
When calling file_put_contents clear the checksum
-rw-r--r-- | lib/private/files/cache/scanner.php | 2 | ||||
-rw-r--r-- | tests/lib/files/view.php | 20 |
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()); + } } |