diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 274ebed05c..e0638ea4ff 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -564,7 +564,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 8ec9619087..9d2b222e07 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -9,6 +9,7 @@ namespace Test\Files; use OC\Cache\CappedMemoryCache; use OC\Files\Cache\Watcher; +use OC\Files\Filesystem; use OC\Files\Storage\Common; use OC\Files\Mount\MountPoint; use OC\Files\Storage\Temporary; @@ -558,6 +559,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 */