From 1b4f24915742f9aaaf03041a972c89be5973c9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Mon, 26 Nov 2012 15:09:02 +0100 Subject: [PATCH] make sure to add the right user as owner of a file to the file cache table --- apps/files_sharing/lib/sharedstorage.php | 21 +++++++++++++++------ lib/filecache.php | 1 - 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index d2489f9cbad..de41750f1da 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -112,12 +112,9 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { if ($path == '' || $path == '/' || !$this->isCreatable(dirname($path))) { return false; } else if ($source = $this->getSourcePath($path)) { - $parts = explode('/', $source, 4); - $user = $parts[1]; - $intPath = '/'.$parts[3]; $storage = OC_Filesystem::getStorage($source); if( ($storage->mkdir($this->getInternalPath($source))) ) { - OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files'); + $this->updateFSCache($path); return true; } } @@ -308,7 +305,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { $intPath = '/'.$parts[3]; $storage = OC_Filesystem::getStorage($source); if( ( $result = $storage->file_put_contents($this->getInternalPath($source), $data) ) ) { - OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files'); + $this->updateFSCache($path); return $result; } } @@ -412,7 +409,7 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { $intPath = '/'.$parts[3]; if ( $write && $storage->touch($this->getInternalPath($source)) ) { - OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files'); + $this->updateFSCache($path); } return $storage->fopen($this->getInternalPath($source), $mode); } @@ -467,4 +464,16 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { //TODO return false; } + + private function updateFSCache($path) { + $source = $this->getSourcePath($path); + $parts = explode('/', $source, 4); + $user = $parts[1]; + $intPath = '/'.$parts[3]; + + $mtime = $this->filemtime($path); + $size = $this->filesize($path); + $mime = $this->getMimeType($path); + OC_FileCache::put($intPath ,array('user'=>$user, 'size'=>$size, 'mtime'=>$mtime, 'mimetype'=>$mime, 'writable'=>true),'/'.$user.'/files'); + } } diff --git a/lib/filecache.php b/lib/filecache.php index e7b5374e4a9..6a1b1f384ad 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -537,7 +537,6 @@ class OC_FileCache{ $fullPath = OC_Filesystem::normalizePath($root.'/'.$path); $sharedPos = strpos($fullPath, '/Shared/'); if ( $sharedPos !== false && ($source = OC_Files_Sharing_Util::getSourcePath(substr($fullPath, $sharedPos+8))) ) { - $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path)); $parts = explode('/', $source, 4); $root = '/'.$parts[1].'/files'; $path = '/'.$parts[3];