Skip to content

Commit

Permalink
Fixes over OCS Optimization
Browse files Browse the repository at this point in the history
- Missing constant TOKEN_LENGTH fix
- Fix when sharing a folder (we dont create a version of folders)
- Fix when retrieving share information from a folder (it was trying to
access the "version" of the folder)
  • Loading branch information
nadir committed Mar 2, 2016
1 parent cbda773 commit bd4d65d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
24 changes: 18 additions & 6 deletions apps/files_sharing/api/customlocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static function createShare($params)
$data['token'] = $token;
}

return new \OC_OCS_Result([$data]);
return new \OC_OCS_Result($data);
}
else
{
Expand Down Expand Up @@ -264,9 +264,13 @@ private static function getSharedFilesInFolder($path)
$basename = basename($versionMeta['eospath']);

if($row['item_type'] === 'file')
{
$realfile = $dirname . "/" . substr($basename, 8);
else
$realfile = $dirname . "/" . $basename;
}
else
{
$realfile = $dirname . "/" . $basename;
}

//$realfile = $dirname . "/" . substr($basename, 8);

Expand Down Expand Up @@ -303,6 +307,7 @@ private static function getSharedFileInfo($path)
{
$username = \OCP\User::getUser();
$view = new \OC\Files\View('/'.$username.'/files');
$fileInfo = $view->getFileInfo($path);

$eosPath = EosProxy::toEos('files' . $path, 'object::user:'.$username);
$originalEosMeta = EosUtil::getFileByEosPath($eosPath);
Expand All @@ -311,9 +316,16 @@ private static function getSharedFileInfo($path)
{
$dirname = dirname($eosPath);
$basename = basename($eosPath);
$versionFolder = $dirname . "/.sys.v#." . $basename;

$eosMeta = EosUtil::getFileByEosPath($versionFolder, false);
$eosMeta = null;
if($fileInfo['eostype'] === 'file')
{
$versionFolder = $dirname . "/.sys.v#." . $basename;
$eosMeta = EosUtil::getFileByEosPath($versionFolder, false);
}
else
{
$eosMeta = $fileInfo;
}

if($eosMeta === null)
{
Expand Down
2 changes: 1 addition & 1 deletion apps/files_sharing/api/linkshareexecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function checkForPreviousShares()
if (isset($oldToken)) {
$this->token = $oldToken;
} else {
$this->token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(self::TOKEN_LENGTH,
$this->token = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(\OC\Share\Share::TOKEN_LENGTH,
\OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_UPPER.
\OCP\Security\ISecureRandom::CHAR_DIGITS);
}
Expand Down
13 changes: 11 additions & 2 deletions apps/files_sharing/api/shareexecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ public function __construct($path)
{
$view = new \OC\Files\View('/'.\OCP\User::getUser().'/files');
$this->meta = $view->getFileInfo($path);
$this->versionMeta = \OC\Files\ObjectStore\EosUtil::getVersionFolderFromFileId($this->meta['fileid']);

$this->itemSource = $this->versionMeta['fileid'];
$this->itemType = $this->meta['mimetype'] === 'httpd/unix-directory' ? 'folder' : 'file';

if($this->itemType === 'file')
{
$this->versionMeta = \OC\Files\ObjectStore\EosUtil::getVersionFolderFromFileId($this->meta['fileid']);
}
else
{
$this->versionMeta = $this->meta;
}

$this->itemSource = $this->versionMeta['fileid'];

if($this->itemSource === null)
{
throw new \Exception("wrong path, file/folder doesn't exist.");
Expand Down

0 comments on commit bd4d65d

Please sign in to comment.