Fixed quota stream to not wrap read-only fopen calls
This commit is contained in:
parent
d8b245490b
commit
c8df27de73
2 changed files with 23 additions and 1 deletions
|
@ -95,7 +95,7 @@ class Quota extends Wrapper {
|
|||
public function fopen($path, $mode) {
|
||||
$source = $this->storage->fopen($path, $mode);
|
||||
$free = $this->free_space('');
|
||||
if ($free >= 0) {
|
||||
if ($free >= 0 && $mode !== 'r') {
|
||||
return \OC\Files\Stream\Quota::wrap($source, $free);
|
||||
} else {
|
||||
return $source;
|
||||
|
|
|
@ -58,4 +58,26 @@ class Quota extends \Test\Files\Storage\Storage {
|
|||
fclose($stream);
|
||||
$this->assertEquals('foobarqwe', $instance->file_get_contents('foo'));
|
||||
}
|
||||
|
||||
public function testReturnRegularStreamOnRead(){
|
||||
$instance = $this->getLimitedStorage(9);
|
||||
|
||||
// create test file first
|
||||
$stream = $instance->fopen('foo', 'w+');
|
||||
fwrite($stream, 'blablacontent');
|
||||
fclose($stream);
|
||||
|
||||
$stream = $instance->fopen('foo', 'r');
|
||||
$meta = stream_get_meta_data($stream);
|
||||
$this->assertEquals('plainfile', $meta['wrapper_type']);
|
||||
fclose($stream);
|
||||
}
|
||||
|
||||
public function testReturnQuotaStreamOnWrite(){
|
||||
$instance = $this->getLimitedStorage(9);
|
||||
$stream = $instance->fopen('foo', 'w+');
|
||||
$meta = stream_get_meta_data($stream);
|
||||
$this->assertEquals('user-space', $meta['wrapper_type']);
|
||||
fclose($stream);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue