From b4e2d8f8adf100654a45bd7ab1d8fa3d482b7e9a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 6 Jun 2019 16:09:27 +0200 Subject: [PATCH 1/2] handle storage exceptions when trying to set mtime not all storage backends can handle setting the mtime and they might not always handle that error correctly. Signed-off-by: Robin Appelman --- lib/private/Files/View.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index fef6153fb9..2516b782ee 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -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. From 000898d932abd60ef1ae9f2167c437864f19087a Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Fri, 21 Jun 2019 16:23:47 +0200 Subject: [PATCH 2/2] fix tests Signed-off-by: Robin Appelman --- tests/lib/Files/ViewTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 7a32736adb..4697dbe89d 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -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 */