diff options
author | Robin Appelman <icewind@owncloud.com> | 2013-10-29 14:18:57 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2013-10-29 14:18:57 +0100 |
commit | b3626f34cd0df127d742f7a8cb2a4ddf929ff886 (patch) | |
tree | cfa75b56cfeadc36313f047ffbb2c0ca7c09a669 /tests | |
parent | b0b76fe064860d2074c91897a29e0f9ac5705db8 (diff) | |
download | nextcloud-server-b3626f34cd0df127d742f7a8cb2a4ddf929ff886.tar.gz nextcloud-server-b3626f34cd0df127d742f7a8cb2a4ddf929ff886.zip |
Update the parent folders storage_mtime on write and delete to prevent rescans
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/cache/updater.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/lib/files/cache/updater.php b/tests/lib/files/cache/updater.php index 5d7997b0544..a891f2560c4 100644 --- a/tests/lib/files/cache/updater.php +++ b/tests/lib/files/cache/updater.php @@ -9,6 +9,7 @@ namespace Test\Files\Cache; use \OC\Files\Filesystem as Filesystem; +use OC\Files\Storage\Temporary; class Updater extends \PHPUnit_Framework_TestCase { /** @@ -265,4 +266,35 @@ class Updater extends \PHPUnit_Framework_TestCase { $this->assertEquals($time, $cachedData['mtime']); } + public function testUpdatePermissionsOnRescanOnlyForUpdatedFile() { + $permissionsCache = $this->storage->getPermissionsCache(); + $scanner = $this->storage->getScanner(); + $scanner->scan(''); + $cache = $this->storage->getCache(); + $loggedInUser = \OC_User::getUser(); + \OC_User::setUserId(self::$user); + FileSystem::getDirectoryContent('/'); + $past = time() - 600; + $cache->put('', array('storage_mtime' => $past)); + + $this->assertNotEquals(-1, $permissionsCache->get($cache->getId('foo.txt'), self::$user)); + $this->assertNotEquals(-1, $permissionsCache->get($cache->getId('foo.png'), self::$user)); + + $permissionsCache->set($cache->getId('foo.png'), self::$user, 15); + FileSystem::file_put_contents('/foo.txt', 'asd'); + + $this->assertEquals(-1, $permissionsCache->get($cache->getId('foo.txt'), self::$user)); + $this->assertEquals(15, $permissionsCache->get($cache->getId('foo.png'), self::$user)); + + FileSystem::getDirectoryContent('/'); + + $this->assertEquals(15, $permissionsCache->get($cache->getId('foo.png'), self::$user)); + + FileSystem::file_put_contents('/qwerty.txt', 'asd'); + FileSystem::getDirectoryContent('/'); + + $this->assertEquals(15, $permissionsCache->get($cache->getId('foo.png'), self::$user)); + + \OC_User::setUserId($loggedInUser); + } } |