Merge pull request #24098 from owncloud/fix_23782

When calling file_put_contents clear the checksum
This commit is contained in:
Thomas Müller 2016-04-20 20:37:01 +02:00
commit cdcabbd0b3
2 changed files with 22 additions and 0 deletions

View File

@ -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'])) {

View File

@ -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());
}
}