Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2019-01-22 17:32:48 +0300
committerBackportbot <backportbot-noreply@rullzer.com>2019-01-22 18:14:34 +0300
commit9126cdc7a88460c4c8c11c4e6ce29b7a2df932b5 (patch)
tree8d95a3317e3d6550c0ce4fc3e6e7f082d8298a4d /tests
parente898c52eb0dd52c2db60ba0a78f0434dc4635fee (diff)
cleanup shared lock if changing to exclusive lock failed
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Files/ViewTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 33d5cc0a8a6..8ac7433aaa2 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -1987,6 +1987,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
*