diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-01-22 16:11:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-22 16:11:46 +0100 |
commit | 90e985fe4f3df5174611490923b91457f6afc342 (patch) | |
tree | 115d66f4c114f21e93fdabe361bb42d08cd1cf2c /tests | |
parent | 0d33302350faba0eb7cf543d8eef225c7e77fddd (diff) | |
parent | f69c2d1e8443ae23278fdf809b027f9713e3f868 (diff) | |
download | nextcloud-server-90e985fe4f3df5174611490923b91457f6afc342.tar.gz nextcloud-server-90e985fe4f3df5174611490923b91457f6afc342.zip |
Merge pull request #13739 from nextcloud/cache-cleanup-change
cleanup shared lock if changing to exclusive lock failed
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/ViewTest.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 97e3d42684f..7a32736adb3 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1997,6 +1997,37 @@ class ViewTest extends \Test\TestCase { $this->assertNull($this->getFileLockType($view, $path), 'File got unlocked after exception'); } + public function testLockBasicOperationUnlocksAfterLockException() { + $view = new View('/' . $this->user . '/files/'); + + $storage = new Temporary([]); + + Filesystem::mount($storage, array(), $this->user . '/'); + + $storage->mkdir('files'); + $storage->mkdir('files/dir'); + $storage->file_put_contents('files/test.txt', 'blah'); + $storage->getScanner()->scan('files'); + + // get a shared lock + $handle = $view->fopen('test.txt', 'r'); + + $thrown = false; + try { + // try (and fail) to get a write lock + $view->unlink('test.txt'); + } catch (\Exception $e) { + $thrown = true; + $this->assertInstanceOf(LockedException::class, $e); + } + $this->assertTrue($thrown, 'Exception was rethrown'); + + // clean shared lock + fclose($handle); + + $this->assertNull($this->getFileLockType($view, 'test.txt'), 'File got unlocked'); + } + /** * Test locks for fopen with fclose at the end * |