Use /files in view fakeRoot ref #99
This commit is contained in:
parent
cc0fa14988
commit
4dc1064d44
@ -48,12 +48,16 @@ class Db_Session extends \OCA\Documents\Db {
|
||||
if (!$oldSession->hasData()){
|
||||
|
||||
//TODO: check if genesis document is a valid odt
|
||||
$genesisPath = $ownerView->storeDocument($ownerView, $path);
|
||||
$genesisPath = $ownerView->storeDocument(
|
||||
$file->getOwner(),
|
||||
$path
|
||||
);
|
||||
|
||||
if (!$genesisPath){
|
||||
throw new \Exception('Unable to copy document. Check permissions and make sure you have enought free space.');
|
||||
}
|
||||
|
||||
$hash = $ownerView->getHashByGenesis($genesisPath);
|
||||
$hash = $ownerView->getHashByGenesis($file->getOwner(), $genesisPath);
|
||||
|
||||
$newSession = new Db_Session(array(
|
||||
$genesisPath, $hash, $file->getOwner(), $file->getFileId()
|
||||
|
10
lib/file.php
10
lib/file.php
@ -103,7 +103,15 @@ class File {
|
||||
$this->owner = $owner;
|
||||
}
|
||||
|
||||
$view = new View('/' . $this->owner);
|
||||
/* to emit hooks properly, view root should contain /user/files */
|
||||
|
||||
if (strpos($this->path, 'files') === 0){
|
||||
$this->path = preg_replace('|^files|', '', $this->path);
|
||||
$view = new View('/' . $this->owner . '/files');
|
||||
} else {
|
||||
$view = new View('/' . $this->owner);
|
||||
}
|
||||
|
||||
if (!$view->file_exists($this->path)){
|
||||
throw new \Exception($this->path . ' doesn\'t exist');
|
||||
}
|
||||
|
10
lib/view.php
10
lib/view.php
@ -34,10 +34,13 @@ class View extends \OC\Files\View{
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
public function storeDocument($ownerView, $filePath){
|
||||
public function storeDocument($owner, $filePath){
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
$ownerView = new View('/' . $owner);
|
||||
$filePath = '/files' . $filePath;
|
||||
|
||||
if (!$ownerView->file_exists($filePath)){
|
||||
throw new \Exception($filePath . ' doesn\'t exist');
|
||||
}
|
||||
@ -57,7 +60,8 @@ class View extends \OC\Files\View{
|
||||
return $newName;
|
||||
}
|
||||
|
||||
public function getHashByGenesis($genesisPath){
|
||||
return sha1($this->file_get_contents(self::DOCUMENTS_DIRNAME . $genesisPath));
|
||||
public function getHashByGenesis($owner, $genesisPath){
|
||||
$ownerView = new View('/' . $owner);
|
||||
return sha1($ownerView->file_get_contents(self::DOCUMENTS_DIRNAME . $genesisPath));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user