summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-10-30 02:31:08 -0700
committerVincent Petry <pvince81@owncloud.com>2013-10-30 02:31:08 -0700
commitde342a5ac7bade9416c51bd925504e52c1595334 (patch)
treea5a493777e0cf43a7e67f721ac4b6401f760676c /lib
parent54ae799cd99c77336814d7cbccb01daff8988a19 (diff)
parente1e4c7c21445d28986c23adf74e67c1c75960ef7 (diff)
downloadnextcloud-server-de342a5ac7bade9416c51bd925504e52c1595334.tar.gz
nextcloud-server-de342a5ac7bade9416c51bd925504e52c1595334.zip
Merge pull request #5603 from owncloud/fix_file_cache_updater_master
Fix file cache updater (backport to master of #5513)
Diffstat (limited to 'lib')
-rw-r--r--lib/private/files/cache/updater.php51
1 files changed, 39 insertions, 12 deletions
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 1f30173a8f8..48fb3ba6c5c 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -95,6 +95,24 @@ class Updater {
}
/**
+ * @brief get file owner and path
+ * @param string $filename
+ * @return array with the oweners uid and the owners path
+ */
+ private static function getUidAndFilename($filename) {
+
+ $uid = \OC\Files\Filesystem::getOwner($filename);
+ \OC\Files\Filesystem::initMountPoints($uid);
+
+ if ($uid != \OCP\User::getUser()) {
+ $info = \OC\Files\Filesystem::getFileInfo($filename);
+ $ownerView = new \OC\Files\View('/' . $uid . '/files');
+ $filename = $ownerView->getPath($info['fileid']);
+ }
+ return array($uid, '/files/' . $filename);
+ }
+
+ /**
* Update the mtime and ETag of all parent folders
*
* @param string $path
@@ -102,23 +120,32 @@ class Updater {
*/
static public function correctFolder($path, $time) {
if ($path !== '' && $path !== '/') {
- $parent = dirname($path);
- if ($parent === '.' || $parent === '\\') {
- $parent = '';
- }
+
+ list($owner, $realPath) = self::getUidAndFilename(dirname($path));
+
/**
* @var \OC\Files\Storage\Storage $storage
* @var string $internalPath
*/
- list($storage, $internalPath) = self::resolvePath($parent);
- if ($storage) {
- $cache = $storage->getCache();
- $id = $cache->getId($internalPath);
- if ($id !== -1) {
- $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
- self::correctFolder($parent, $time);
+ $view = new \OC\Files\View('/' . $owner);
+
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
+
+ while ($id !== -1) {
+ $cache->update($id, array('mtime' => $time, 'etag' => $storage->getETag($internalPath)));
+ if ($realPath !== '') {
+ $realPath = dirname($realPath);
+ if($realPath === '/') {
+ $realPath = "";
+ }
+ // check storage for parent in case we change the storage in this step
+ list($storage, $internalPath) = $view->resolvePath($realPath);
+ $cache = $storage->getCache();
+ $id = $cache->getId($internalPath);
} else {
- Util::writeLog('core', 'Path not in cache: '.$internalPath, Util::ERROR);
+ $id = -1;
}
}
}