Merge pull request #21216 from owncloud/fopen-statcache
Clear SMB statcache after fopen
This commit is contained in:
commit
24271cf953
|
@ -33,6 +33,7 @@ use Icewind\SMB\Exception\Exception;
|
||||||
use Icewind\SMB\Exception\NotFoundException;
|
use Icewind\SMB\Exception\NotFoundException;
|
||||||
use Icewind\SMB\NativeServer;
|
use Icewind\SMB\NativeServer;
|
||||||
use Icewind\SMB\Server;
|
use Icewind\SMB\Server;
|
||||||
|
use Icewind\Streams\CallbackWrapper;
|
||||||
use Icewind\Streams\IteratorDirectory;
|
use Icewind\Streams\IteratorDirectory;
|
||||||
use OC\Files\Filesystem;
|
use OC\Files\Filesystem;
|
||||||
|
|
||||||
|
@ -189,7 +190,10 @@ class SMB extends Common {
|
||||||
return $this->share->read($fullPath);
|
return $this->share->read($fullPath);
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'wb':
|
case 'wb':
|
||||||
return $this->share->write($fullPath);
|
$source = $this->share->write($fullPath);
|
||||||
|
return CallBackWrapper::wrap($source, null, null, function () use ($fullPath) {
|
||||||
|
unset($this->statCache[$fullPath]);
|
||||||
|
});
|
||||||
case 'a':
|
case 'a':
|
||||||
case 'ab':
|
case 'ab':
|
||||||
case 'r+':
|
case 'r+':
|
||||||
|
@ -219,7 +223,8 @@ class SMB extends Common {
|
||||||
}
|
}
|
||||||
$source = fopen($tmpFile, $mode);
|
$source = fopen($tmpFile, $mode);
|
||||||
$share = $this->share;
|
$share = $this->share;
|
||||||
return CallBackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) {
|
return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) {
|
||||||
|
unset($this->statCache[$fullPath]);
|
||||||
$share->put($tmpFile, $fullPath);
|
$share->put($tmpFile, $fullPath);
|
||||||
unlink($tmpFile);
|
unlink($tmpFile);
|
||||||
});
|
});
|
||||||
|
|
|
@ -598,4 +598,17 @@ abstract class Storage extends \Test\TestCase {
|
||||||
$this->instance->mkdir('source');
|
$this->instance->mkdir('source');
|
||||||
$this->assertTrue($this->instance->isSharable('source'));
|
$this->assertTrue($this->instance->isSharable('source'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStatAfterWrite() {
|
||||||
|
$this->instance->file_put_contents('foo.txt', 'bar');
|
||||||
|
$stat = $this->instance->stat('foo.txt');
|
||||||
|
$this->assertEquals(3, $stat['size']);
|
||||||
|
|
||||||
|
$fh = $this->instance->fopen('foo.txt', 'w');
|
||||||
|
fwrite($fh, 'qwerty');
|
||||||
|
fclose($fh);
|
||||||
|
|
||||||
|
$stat = $this->instance->stat('foo.txt');
|
||||||
|
$this->assertEquals(6, $stat['size']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue