Skip to content

Commit

Permalink
Merge pull request #16038 from nextcloud/backport/15889/stable16
Browse files Browse the repository at this point in the history
[stable16] handle storage exceptions when trying to set mtime
  • Loading branch information
rullzer committed Jun 25, 2019
2 parents e69e2c5 + b22fca4 commit 870a330
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/Files/View.php
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions tests/lib/Files/ViewTest.php
Expand Up @@ -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 */
Expand Down

0 comments on commit 870a330

Please sign in to comment.