diff --git a/ajax/sessionController.php b/ajax/sessionController.php
index 51502570..6405431d 100644
--- a/ajax/sessionController.php
+++ b/ajax/sessionController.php
@@ -101,9 +101,10 @@ class SessionController extends Controller{
}
$sessionData = $session->getData();
try {
- $file = new File($sessionData['file_id']);
if ($isGuest){
- $file->setToken('yes');
+ $file = File::getByShareToken($currentMemberData['token']);
+ } else {
+ $file = new File($sessionData['file_id']);
}
list($view, $path) = $file->getOwnerViewAndPath();
@@ -128,8 +129,7 @@ class SessionController extends Controller{
// Active users except current user
$memberCount = count($memberIds) - 1;
- if ($view->file_exists($path)){
-
+ if ($view->file_exists($path)){
$proxyStatus = \OC_FileProxy::$enabled;
\OC_FileProxy::$enabled = false;
$currentHash = sha1($view->file_get_contents($path));
@@ -152,7 +152,6 @@ class SessionController extends Controller{
if ($memberCount>0){
// Update genesis hash to prevent conflicts
Helper::debugLog('Update hash');
-
$session->updateGenesisHash($esId, sha1($data['content']));
} else {
// Last user. Kill session data
diff --git a/appinfo/database.xml b/appinfo/database.xml
index 7a193802..e11d3913 100644
--- a/appinfo/database.xml
+++ b/appinfo/database.xml
@@ -99,6 +99,13 @@
true
1
+
+ token
+ text
+
+ false
+ 32
+
status
integer
diff --git a/appinfo/version b/appinfo/version
index ce609caf..c18d72be 100755
--- a/appinfo/version
+++ b/appinfo/version
@@ -1 +1 @@
-0.8
\ No newline at end of file
+0.8.1
\ No newline at end of file
diff --git a/lib/db/member.php b/lib/db/member.php
index 7e544590..73b13c22 100644
--- a/lib/db/member.php
+++ b/lib/db/member.php
@@ -23,8 +23,8 @@ class Db_Member extends Db{
protected $tableName = '`*PREFIX*documents_member`';
- protected $insertStatement = 'INSERT INTO `*PREFIX*documents_member` (`es_id`, `uid`, `color`, `last_activity`, `is_guest`)
- VALUES (?, ?, ?, ?, ?)';
+ protected $insertStatement = 'INSERT INTO `*PREFIX*documents_member` (`es_id`, `uid`, `color`, `last_activity`, `is_guest`, `token`)
+ VALUES (?, ?, ?, ?, ?, ?)';
protected $loadStatement = 'SELECT * FROM `*PREFIX*documents_member` WHERE `member_id`= ?';
diff --git a/lib/db/session.php b/lib/db/session.php
index 19f123da..1cd726f3 100644
--- a/lib/db/session.php
+++ b/lib/db/session.php
@@ -68,7 +68,8 @@ class Db_Session extends \OCA\Documents\Db {
$uid,
$memberColor,
time(),
- intval($file->isPublicShare())
+ intval($file->isPublicShare()),
+ $file->getToken()
));
if ($member->insert()){
diff --git a/lib/file.php b/lib/file.php
index c22b9533..1dad0133 100644
--- a/lib/file.php
+++ b/lib/file.php
@@ -54,23 +54,12 @@ class File {
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
// seems to be a valid share
$rootLinkItem = \OCP\Share::resolveReShare($linkItem);
- $fileOwner = $rootLinkItem['uid_owner'];
} else {
throw new \Exception('This file was probably unshared');
}
- if (!isset($rootLinkItem['path']) && isset($rootLinkItem['file_target'])){
- $rootLinkItem['path'] = $rootLinkItem['file_target'];
- }
$file = new File($rootLinkItem['file_source'], array($rootLinkItem));
$file->setToken($token);
-
- if (isset($rootLinkItem['uid_owner'])){
- \OC_Util::tearDownFS();
- \OC_Util::setupFS($rootLinkItem['uid_owner']);
- $file->setOwner($rootLinkItem['uid_owner']);
- $file->setPath(\OC\Files\Filesystem::getPath($linkItem['file_source']));
- }
if (isset($linkItem['share_with']) && !empty($linkItem['share_with'])){
$file->setPasswordProtected(true);
@@ -79,6 +68,10 @@ class File {
return $file;
}
+ public function getToken($token){
+ return $this->token;
+ }
+
public function getFileId(){
return $this->fileId;
}
@@ -156,28 +149,34 @@ class File {
* @throws \Exception
*/
public function getOwnerViewAndPath(){
- if (!$this->owner || !$this->path){
- if ($this->isPublicShare()){
- list($owner, $path) = $this->getSharedFileOwnerAndPath();
+ if ($this->isPublicShare()){
+ $rootLinkItem = \OCP\Share::resolveReShare($this->sharing[0]);
+ if (isset($rootLinkItem['uid_owner'])){
+ $owner = $rootLinkItem['uid_owner'];
} else {
- $owner = \OCP\User::getUser();
- $path = Storage::resolvePath($this->fileId);
- if (!$path){
- throw new \Exception($this->fileId . ' can not be resolved');
- }
+ throw new \Exception($this->fileId . ' is a broken share');
}
+ $view = new View('/' . $owner . '/files');
+ $path = $rootLinkItem['file_target'];
+ } else {
+ $owner = \OCP\User::getUser();
+ $view = new View('/' . $this->owner);
+ $path = $view->getPath($this->fileId);
+ }
- $this->path = $path;
- $this->owner = $owner;
+ if (!$path){
+ throw new \Exception($this->fileId . ' can not be resolved');
}
+ $this->path = $path;
+ $this->owner = $owner;
- $view = new View('/' . $this->owner . '/files');
if (!$view->file_exists($this->path)){
throw new \Exception($this->path . ' doesn\'t exist');
}
return array($view, $this->path);
}
+
public function getOwner(){
if (!$this->owner){
@@ -186,28 +185,6 @@ class File {
return $this->owner;
}
- /**
- * public links only
- * @return array
- */
- protected function getSharedFileOwnerAndPath(){
- foreach ($this->sharing as $share){
- $rootLinkItem = \OCP\Share::resolveReShare($share);
- if (isset($rootLinkItem['uid_owner'])){
- $owner = $rootLinkItem['uid_owner'];
- } else {
- $owner = false;
- }
- $view = new View('/' . $owner . '/files');
-
- return array(
- $owner,
- $view->getPath($rootLinkItem['file_source'])
- );
- }
-
- return $result;
- }
protected function getPassword(){
return $this->sharing[0]['share_with'];
diff --git a/lib/genesis.php b/lib/genesis.php
index 7731387e..c00c197b 100644
--- a/lib/genesis.php
+++ b/lib/genesis.php
@@ -38,8 +38,8 @@ class Genesis {
* @param OCA\Documents\File $file
* */
public function __construct(\OCA\Documents\File $file){
- $owner = $file->getOwner();
list($view, $path) = $file->getOwnerViewAndPath();
+ $owner = $file->getOwner();
$this->view = new View('/' . $owner);