Merge pull request #16038 from nextcloud/backport/15889/stable16

[stable16] handle storage exceptions when trying to set mtime
This commit is contained in:
Roeland Jago Douma 2019-06-25 21:48:34 +02:00 committed by GitHub
commit 870a330abb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -566,7 +566,12 @@ class View {
$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.

View File

@ -1962,6 +1962,9 @@ class ViewTest extends \Test\TestCase {
$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 */