From 8de4209c3ef01889bc3aa487137129c3911ca235 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 27 Mar 2017 17:04:55 +0200 Subject: [PATCH] round the mtime in touch Signed-off-by: Robin Appelman --- lib/private/Files/View.php | 2 +- tests/lib/Files/ViewTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 506128d7fcd..85c70a1015e 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -569,7 +569,7 @@ class View { $mtime = time(); } //if native touch fails, we emulate it by changing the mtime in the cache - $this->putFileInfo($path, array('mtime' => $mtime)); + $this->putFileInfo($path, array('mtime' => floor($mtime))); } return true; } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 3635323e169..f1e1ee7d417 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -588,6 +588,23 @@ class ViewTest extends \Test\TestCase { $this->assertEquals($cachedData['storage_mtime'], $cachedData['mtime']); } + /** + * @medium + */ + public function testTouchFloat() { + $storage = $this->getTestStorage(true, TemporaryNoTouch::class); + + Filesystem::mount($storage, array(), '/'); + + $rootView = new View(''); + $oldCachedData = $rootView->getFileInfo('foo.txt'); + + $rootView->touch('foo.txt', 500.5); + + $cachedData = $rootView->getFileInfo('foo.txt'); + $this->assertEquals(500, $cachedData['mtime']); + } + /** * @medium */ -- 2.39.5