]> source.dussan.org Git - nextcloud-server.git/commitdiff
round the mtime in touch 4919/head
authorRobin Appelman <robin@icewind.nl>
Mon, 27 Mar 2017 15:04:55 +0000 (17:04 +0200)
committerRobin Appelman <robin@icewind.nl>
Thu, 18 May 2017 11:22:52 +0000 (13:22 +0200)
Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/Files/View.php
tests/lib/Files/ViewTest.php

index 274ebed05c3d69fd8e5b241b989a13fd167ff6fd..e0638ea4ff7176dfee70f0b711ead4c543998a31 100644 (file)
@@ -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;
        }
index 8ec9619087c7f4244f3a85a006c465e2ddfb961b..9d2b222e07c8ba12d4de2c1861d0a548ae607823 100644 (file)
@@ -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
         */