Merge pull request #581 from schiesbn/add_user_to_fscache

make sure to add the right user as owner of a file to the file cache table
remotes/origin/stable45
Björn Schießle 2012-11-26 08:47:45 +07:00
commit d6bc7757ab
2 changed files with 15 additions and 7 deletions

@ -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');
}
}

@ -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];