From 166edb2cc14f9587bf95089149e0a4305b5d9832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 6 Nov 2012 13:28:42 +0100 Subject: [PATCH 1/9] start implementing a solution to fix broken etags for shared files --- lib/connector/sabre/node.php | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index f87e9f9a0b1..01a4bd141a6 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -148,25 +148,38 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return bool|array */ public function updateProperties($properties) { + // get source path of shared files + if (!strncmp($this->path, '/Shared/', 8)) { + $source = OC_Filestorage_Shared::getSourcePath(str_replace('/Shared/', '', $this->path)); + $parts = explode('/', $source, 4); + $user = $parts[1]; + $path = '/'.$parts[3]; + } else { + $user = OC_User::getUser(); + $path = $this->path; + } + $existing = $this->getProperties(array()); foreach($properties as $propertyName => $propertyValue) { // If it was null, we need to delete the property if (is_null($propertyValue)) { if(array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); - $query->execute( array( OC_User::getUser(), $this->path, $propertyName )); + $query->execute( array( $user, $path, $propertyName )); } } else { if( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0 ) { + error_log("propertyName: " . $propertyName); $this->touch($propertyValue); } else { + error_log("update/insert property: user: $user; path: $path"); if(!array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); - $query->execute( array( OC_User::getUser(), $this->path, $propertyName,$propertyValue )); + $query->execute( array( $user, $path, $propertyName, $propertyValue )); } else { $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ? WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); - $query->execute( array( $propertyValue,OC_User::getUser(), $this->path, $propertyName )); + $query->execute( array( $propertyValue, $user, $path, $propertyName )); } } } @@ -188,6 +201,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return array */ public function getProperties($properties) { + //TODO: Shared files?!? if (is_null($this->property_cache)) { $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?' ); $result = $query->execute( array( OC_User::getUser(), $this->path )); @@ -234,9 +248,19 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr if (empty($tag)) { return null; } + + if (!strncmp($path, '/Shared/', 8)) { + $source = OC_Filestorage_Shared::getSourcePath(str_replace('/Shared/', '', $path)); + $parts = explode('/', $source, 4); + $user = $parts[1]; + $path = '/'.$parts[3]; + } else { + $user = OC_User::getUser(); + } + $etag = '"'.$tag.'"'; $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); - $query->execute( array( OC_User::getUser(), $path, self::GETETAG_PROPERTYNAME, $etag )); + $query->execute( array( $user, $path, self::GETETAG_PROPERTYNAME, $etag )); return $etag; } @@ -246,6 +270,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr */ static public function removeETagPropertyForPath($path) { // remove tags from this and parent paths + //TODO Shared Files?!? $paths = array(); while ($path != '/' && $path != '.' && $path != '' && $path != '\\') { $paths[] = $path; From 72d6c3246f32223e8128d4b35b2f004853c8f08a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 6 Nov 2012 14:38:34 +0100 Subject: [PATCH 2/9] find correct source file and owner of shared files --- lib/connector/sabre/node.php | 52 +++++++++++++++++------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 01a4bd141a6..a740fe6cac1 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -149,37 +149,27 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr */ public function updateProperties($properties) { // get source path of shared files - if (!strncmp($this->path, '/Shared/', 8)) { - $source = OC_Filestorage_Shared::getSourcePath(str_replace('/Shared/', '', $this->path)); - $parts = explode('/', $source, 4); - $user = $parts[1]; - $path = '/'.$parts[3]; - } else { - $user = OC_User::getUser(); - $path = $this->path; - } - + $source = self::getFileSource($this->path); + $existing = $this->getProperties(array()); foreach($properties as $propertyName => $propertyValue) { // If it was null, we need to delete the property if (is_null($propertyValue)) { if(array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); - $query->execute( array( $user, $path, $propertyName )); + $query->execute( array( $source['user'], $source['path'], $propertyName )); } } else { if( strcmp( $propertyName, self::LASTMODIFIED_PROPERTYNAME) === 0 ) { - error_log("propertyName: " . $propertyName); $this->touch($propertyValue); } else { - error_log("update/insert property: user: $user; path: $path"); if(!array_key_exists( $propertyName, $existing )) { $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); - $query->execute( array( $user, $path, $propertyName, $propertyValue )); + $query->execute( array( $source['user'], $source['path'], $propertyName, $propertyValue )); } else { $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ? WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); - $query->execute( array( $propertyValue, $user, $path, $propertyName )); + $query->execute( array( $propertyValue, $source['user'], $source['path'], $propertyName )); } } } @@ -249,18 +239,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr return null; } - if (!strncmp($path, '/Shared/', 8)) { - $source = OC_Filestorage_Shared::getSourcePath(str_replace('/Shared/', '', $path)); - $parts = explode('/', $source, 4); - $user = $parts[1]; - $path = '/'.$parts[3]; - } else { - $user = OC_User::getUser(); - } - + $source = self::getFileSource($path); + $etag = '"'.$tag.'"'; $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); - $query->execute( array( $user, $path, self::GETETAG_PROPERTYNAME, $etag )); + $query->execute( array( $source['user'], $source['path'], self::GETETAG_PROPERTYNAME, $etag )); return $etag; } @@ -270,7 +253,10 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr */ static public function removeETagPropertyForPath($path) { // remove tags from this and parent paths - //TODO Shared Files?!? + + $source = self::getFileSource($path); + $path = $source['path']; + $paths = array(); while ($path != '/' && $path != '.' && $path != '' && $path != '\\') { $paths[] = $path; @@ -286,7 +272,19 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr .' AND `propertyname` = ?' .' AND `propertypath` IN ('.$path_placeholders.')' ); - $vals = array( OC_User::getUser(), self::GETETAG_PROPERTYNAME ); + $vals = array( $source['user'], self::GETETAG_PROPERTYNAME ); $query->execute(array_merge( $vals, $paths )); } + + private function getFileSource($path) { + if ( OC_App::isEnabled('files_sharing') && !strncmp($path, '/Shared/', 8)) { + $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path)); + $parts = explode('/', $source, 4); + $user = $parts[1]; + $path = '/'.$parts[3]; + } else { + $user = OC_User::getUser(); + } + return(array('user' => $user, 'path' => $path)); + } } From 56c8976bacc395c9e97ab41e0d068c97dd28e8a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 6 Nov 2012 14:39:30 +0100 Subject: [PATCH 3/9] introduce util.php for file sharing which provides functionallity which is also needed in other places, e.g. the webdav server --- apps/files_sharing/appinfo/app.php | 1 + apps/files_sharing/lib/util.php | 79 ++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 apps/files_sharing/lib/util.php diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 109f86b2e87..bfed4266ad4 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -3,6 +3,7 @@ OC::$CLASSPATH['OC_Share_Backend_File'] = "apps/files_sharing/lib/share/file.php"; OC::$CLASSPATH['OC_Share_Backend_Folder'] = 'apps/files_sharing/lib/share/folder.php'; OC::$CLASSPATH['OC_Filestorage_Shared'] = "apps/files_sharing/lib/sharedstorage.php"; +OC::$CLASSPATH['OC_Files_Sharing_Util'] = "apps/files_sharing/lib/util.php"; OCP\Util::connectHook('OC_Filesystem', 'setup', 'OC_Filestorage_Shared', 'setup'); OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); diff --git a/apps/files_sharing/lib/util.php b/apps/files_sharing/lib/util.php new file mode 100644 index 00000000000..84cddb738a0 --- /dev/null +++ b/apps/files_sharing/lib/util.php @@ -0,0 +1,79 @@ +. + * + */ + + +class OC_Files_Sharing_Util { + + private static $files = array(); + + /** + * @brief Get the source file path and the permissions granted for a shared file + * @param string Shared target file path + * @return Returns array with the keys path and permissions or false if not found + */ + private function getFile($target) { + $target = '/'.$target; + $target = rtrim($target, '/'); + if (isset(self::$files[$target])) { + return self::$files[$target]; + } else { + $pos = strpos($target, '/', 1); + // Get shared folder name + if ($pos !== false) { + $folder = substr($target, 0, $pos); + if (isset(self::$files[$folder])) { + $file = self::$files[$folder]; + } else { + $file = OCP\Share::getItemSharedWith('folder', $folder, OC_Share_Backend_File::FORMAT_SHARED_STORAGE); + } + if ($file) { + self::$files[$target]['path'] = $file['path'].substr($target, strlen($folder)); + self::$files[$target]['permissions'] = $file['permissions']; + return self::$files[$target]; + } + } else { + $file = OCP\Share::getItemSharedWith('file', $target, OC_Share_Backend_File::FORMAT_SHARED_STORAGE); + if ($file) { + self::$files[$target] = $file; + return self::$files[$target]; + } + } + OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, OCP\Util::ERROR); + return false; + } + } + + /** + * @brief Get the source file path for a shared file + * @param string Shared target file path + * @return Returns source file path or false if not found + */ + public static function getSourcePath($target) { + $file = self::getFile($target); + if (isset($file['path'])) { + $uid = substr($file['path'], 1, strpos($file['path'], '/', 1) - 1); + OC_Filesystem::mount('OC_Filestorage_Local', array('datadir' => OC_User::getHome($uid)), $uid); + return $file['path']; + } + return false; + } +} \ No newline at end of file From 5f7d053c3a3690b41f6bf86b452cde035bfa62fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 6 Nov 2012 16:39:58 +0100 Subject: [PATCH 4/9] some more checks if file is a shared file --- lib/connector/sabre/directory.php | 10 +++++++--- lib/connector/sabre/node.php | 13 +++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index 413efef73b7..56c17da1a6e 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -117,16 +117,20 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa */ public function getChildren() { + $source = $this->getFileSource($this->path); + $path = $source['path']; + $user = $source['user']; + $folder_content = OC_Files::getDirectoryContent($this->path); $paths = array(); foreach($folder_content as $info) { - $paths[] = $this->path.'/'.$info['name']; + $paths[] = $path.'/'.$info['name']; } $properties = array_fill_keys($paths, array()); if(count($paths)>0) { $placeholders = join(',', array_fill(0, count($paths), '?')); $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' ); - array_unshift($paths, OC_User::getUser()); // prepend userid + array_unshift($paths, $user); // prepend userid $result = $query->execute( $paths ); while($row = $result->fetchRow()) { $propertypath = $row['propertypath']; @@ -139,7 +143,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $nodes = array(); foreach($folder_content as $info) { $node = $this->getChild($info['name'], $info); - $node->setPropertyCache($properties[$this->path.'/'.$info['name']]); + $node->setPropertyCache($properties[$path.'/'.$info['name']]); $nodes[] = $node; } return $nodes; diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index a740fe6cac1..b116f01cbc7 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -191,17 +191,19 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return array */ public function getProperties($properties) { - //TODO: Shared files?!? - if (is_null($this->property_cache)) { + + $source = self::getFileSource($this->path); + + if (is_null($this->property_cache) || empty($this->property_cache)) { $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?' ); - $result = $query->execute( array( OC_User::getUser(), $this->path )); + $result = $query->execute( array( $source['user'], $source['path'] )); $this->property_cache = array(); while( $row = $result->fetchRow()) { $this->property_cache[$row['propertyname']] = $row['propertyvalue']; } } - + // if the array was empty, we need to return everything if(count($properties) == 0) { return $this->property_cache; @@ -253,7 +255,6 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr */ static public function removeETagPropertyForPath($path) { // remove tags from this and parent paths - $source = self::getFileSource($path); $path = $source['path']; @@ -276,7 +277,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $query->execute(array_merge( $vals, $paths )); } - private function getFileSource($path) { + protected function getFileSource($path) { if ( OC_App::isEnabled('files_sharing') && !strncmp($path, '/Shared/', 8)) { $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path)); $parts = explode('/', $source, 4); From 501bb0afd6da373a57d101269d732dcfadd8fb4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 8 Nov 2012 12:31:39 +0100 Subject: [PATCH 5/9] if file gets modified, always remove etag for all shared folder to make sure that the sync client checks the shared folder for changes --- lib/connector/sabre/node.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index b116f01cbc7..26983be2f8a 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -275,6 +275,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr ); $vals = array( $source['user'], self::GETETAG_PROPERTYNAME ); $query->execute(array_merge( $vals, $paths )); + + //remove etag for all Shared folders + $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties`' + .' WHERE `propertypath` = "/Shared"' + ); + $query->execute(array()); + } protected function getFileSource($path) { From 9e0a6d86ba23bb171c3e2e1309806c74f9c7fbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Thu, 8 Nov 2012 15:23:09 +0100 Subject: [PATCH 6/9] make getFileSource static --- lib/connector/sabre/node.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 26983be2f8a..6a2ad22fd5d 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -284,7 +284,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr } - protected function getFileSource($path) { + protected static function getFileSource($path) { if ( OC_App::isEnabled('files_sharing') && !strncmp($path, '/Shared/', 8)) { $source = OC_Files_Sharing_Util::getSourcePath(str_replace('/Shared/', '', $path)); $parts = explode('/', $source, 4); From 39b6bb8a180312419302f072a3f6a565a0af719f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Fri, 9 Nov 2012 13:13:11 +0100 Subject: [PATCH 7/9] make function static --- apps/files_sharing/lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/lib/util.php b/apps/files_sharing/lib/util.php index 84cddb738a0..2306408dc0e 100644 --- a/apps/files_sharing/lib/util.php +++ b/apps/files_sharing/lib/util.php @@ -30,7 +30,7 @@ class OC_Files_Sharing_Util { * @param string Shared target file path * @return Returns array with the keys path and permissions or false if not found */ - private function getFile($target) { + private static function getFile($target) { $target = '/'.$target; $target = rtrim($target, '/'); if (isset(self::$files[$target])) { From 781b57907491acafec7b3b2eb23475a650fc64e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 13 Nov 2012 15:32:38 +0100 Subject: [PATCH 8/9] 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 6dba76955a0..98f6f3f0e21 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 9ce94c6f733..40d63021273 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); } From 5e19854d47202073773e2cde3eaabdf66099a85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Schie=C3=9Fle?= Date: Tue, 13 Nov 2012 16:04:27 +0100 Subject: [PATCH 9/9] always calll fopen --- apps/files_sharing/lib/sharedstorage.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 98f6f3f0e21..d2489f9cbad 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -413,8 +413,8 @@ class OC_Filestorage_Shared extends OC_Filestorage_Common { if ( $write && $storage->touch($this->getInternalPath($source)) ) { OC_FileCache::put($intPath ,array('user'=>$user), '/'.$user.'/files'); - return $storage->fopen($this->getInternalPath($source), $mode); - } + } + return $storage->fopen($this->getInternalPath($source), $mode); } return false; }