mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
explicitly close source stream on local storage
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
afc2c71bd3
commit
98d3836650
2 changed files with 6 additions and 2 deletions
|
|
@ -568,8 +568,11 @@ class Local extends \OC\Files\Storage\Common {
|
|||
|
||||
public function writeStream(string $path, $stream, int $size = null): int {
|
||||
$result = $this->file_put_contents($path, $stream);
|
||||
if (is_resource($stream)) {
|
||||
fclose($stream);
|
||||
}
|
||||
if ($result === false) {
|
||||
throw new GenericFileException("Failed write steam to $path");
|
||||
throw new GenericFileException("Failed write stream to $path");
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -658,6 +658,7 @@ abstract class Storage extends \Test\TestCase {
|
|||
|
||||
$storage->writeStream('test.txt', $source);
|
||||
$this->assertTrue($storage->file_exists('test.txt'));
|
||||
$this->assertEquals(file_get_contents($textFile), $storage->file_get_contents('test.txt'));
|
||||
$this->assertStringEqualsFile($textFile, $storage->file_get_contents('test.txt'));
|
||||
$this->assertEquals('resource (closed)', gettype($source));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue