diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index fef6153fb9ac0..2516b782ee734 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -566,7 +566,12 @@ public function touch($path, $mtime = null) { $hooks[] = 'create'; $hooks[] = 'write'; } - $result = $this->basicOperation('touch', $path, $hooks, $mtime); + try { + $result = $this->basicOperation('touch', $path, $hooks, $mtime); + } catch (\Exception $e) { + $this->logger->logException($e, ['level' => ILogger::INFO, 'message' => 'Error while setting modified time']); + $result = false; + } if (!$result) { // If create file fails because of permissions on external storage like SMB folders, // check file exists and return false if not. diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 7a32736adb3a3..4697dbe89d898 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1962,6 +1962,9 @@ public function testLockBasicOperationUnlocksAfterException( $operationArgs, $path ) { + if ($operation === 'touch') { + $this->markTestSkipped("touch handles storage exceptions internally"); + } $view = new View('/' . $this->user . '/files/'); /** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage */