Merge pull request #24098 from owncloud/fix_23782
When calling file_put_contents clear the checksum
This commit is contained in:
commit
cdcabbd0b3
|
@ -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'])) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue