[Pkg-owncloud-commits] [owncloud] 87/394: create correct file cache entries for new files/folder created in shared folders
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:11:34 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit 781b57907491acafec7b3b2eb23475a650fc64e1
Author: Björn Schießle <schiessle at owncloud.com>
Date: Tue Nov 13 15:32:38 2012 +0100
create correct file cache entries for new files/folder created in shared folders
---
apps/files_sharing/lib/sharedstorage.php | 38 +++++++++++++++++++++++-------
lib/filecache.php | 12 ++++++----
2 files changed, 37 insertions(+), 13 deletions(-)
diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php
index 6dba769..98f6f3f 100644
--- a/apps/files_sharing/lib/sharedstorage.php
+++ b/apps/files_sharing/lib/sharedstorage.php
@@ -112,8 +112,14 @@ 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);
- return $storage->mkdir($this->getInternalPath($source));
+ if( ($storage->mkdir($this->getInternalPath($source))) ) {
+ OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files');
+ return true;
+ }
}
return false;
}
@@ -296,10 +302,15 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
'target' => $this->sharedFolder.$path,
'source' => $source,
);
- OCP\Util::emitHook('OC_Filestorage_Shared', 'file_put_contents', $info);
+ OCP\Util::emitHook('OC_Filestorage_Shared', 'file_put_contents', $info);
+ $parts = explode('/', $source, 4);
+ $user = $parts[1];
+ $intPath = '/'.$parts[3];
$storage = OC_Filesystem::getStorage($source);
- $result = $storage->file_put_contents($this->getInternalPath($source), $data);
- return $result;
+ if( ( $result = $storage->file_put_contents($this->getInternalPath($source), $data) ) ) {
+ OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files');
+ return $result;
+ }
}
return false;
}
@@ -368,17 +379,18 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
public function fopen($path, $mode) {
if ($source = $this->getSourcePath($path)) {
+ $write = false;
switch ($mode) {
+ case 'w':
+ case 'wb':
+ case 'w+':
+ case 'wb+': $write = true;
case 'r+':
case 'rb+':
- case 'w+':
- case 'wb+':
case 'x+':
case 'xb+':
case 'a+':
case 'ab+':
- case 'w':
- case 'wb':
case 'x':
case 'xb':
case 'a':
@@ -394,7 +406,15 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common {
);
OCP\Util::emitHook('OC_Filestorage_Shared', 'fopen', $info);
$storage = OC_Filesystem::getStorage($source);
- return $storage->fopen($this->getInternalPath($source), $mode);
+
+ $parts = explode('/', $source, 4);
+ $user = $parts[1];
+ $intPath = '/'.$parts[3];
+
+ if ( $write && $storage->touch($this->getInternalPath($source)) ) {
+ OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files');
+ return $storage->fopen($this->getInternalPath($source), $mode);
+ }
}
return false;
}
diff --git a/lib/filecache.php b/lib/filecache.php
index 9ce94c6..40d6302 100644
--- a/lib/filecache.php
+++ b/lib/filecache.php
@@ -79,8 +79,8 @@ class OC_FileCache{
// add parent directory to the file cache if it does not exist yet.
if ($parent == -1 && $fullpath != $root) {
- $parentDir = dirname($path);
- self::scanFile($parentDir);
+ $parentDir = dirname(OC_Filesystem::normalizePath($path));
+ self::scanFile($parentDir, $root);
$parent = self::getParentId($fullpath);
}
@@ -94,15 +94,19 @@ class OC_FileCache{
if(!isset($data['versioned'])) {
$data['versioned']=false;
}
+ if(!isset($data['user'])) {
+ $data['user']=OC_User::getUser();
+ }
+
+
$mimePart=dirname($data['mimetype']);
$data['size']=(int)$data['size'];
$data['ctime']=(int)$data['mtime'];
$data['writable']=(int)$data['writable'];
$data['encrypted']=(int)$data['encrypted'];
$data['versioned']=(int)$data['versioned'];
- $user=OC_User::getUser();
$query=OC_DB::prepare('INSERT INTO `*PREFIX*fscache`(`parent`, `name`, `path`, `path_hash`, `size`, `mtime`, `ctime`, `mimetype`, `mimepart`,`user`,`writable`,`encrypted`,`versioned`) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)');
- $result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$user,$data['writable'],$data['encrypted'],$data['versioned']));
+ $result=$query->execute(array($parent,basename($fullpath),$fullpath,md5($fullpath),$data['size'],$data['mtime'],$data['ctime'],$data['mimetype'],$mimePart,$data['user'],$data['writable'],$data['encrypted'],$data['versioned']));
if(OC_DB::isError($result)) {
OC_Log::write('files','error while writing file('.$fullpath.') to cache',OC_Log::ERROR);
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list