diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-06-09 17:33:57 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-06-09 17:34:13 +0200 |
commit | 601bac746d62540425f7a9e13ffbbc61e12eaca2 (patch) | |
tree | 2a45f95ede3649d4f30a08e53656f077e784441a /apps/files_encryption | |
parent | e7f6f7e452131320a73861ad975c3d7961074190 (diff) | |
download | nextcloud-server-601bac746d62540425f7a9e13ffbbc61e12eaca2.tar.gz nextcloud-server-601bac746d62540425f7a9e13ffbbc61e12eaca2.zip |
use absolute path for file proxies
Diffstat (limited to 'apps/files_encryption')
-rw-r--r-- | apps/files_encryption/lib/cryptstream.php | 6 | ||||
-rw-r--r-- | apps/files_encryption/lib/proxy.php | 2 | ||||
-rw-r--r-- | apps/files_encryption/tests/proxy.php | 15 |
3 files changed, 21 insertions, 2 deletions
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index d6643f32689..a698ee00335 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -35,8 +35,12 @@ class OC_CryptStream{ private $meta=array();//header/meta for source stream private $count; private $writeCache; + private static $rootView; public function stream_open($path, $mode, $options, &$opened_path){ + if(!self::$rootView){ + self::$rootView=new OC_FilesystemView(''); + } $path=str_replace('crypt://','',$path); if(dirname($path)=='streams' and isset(self::$sourceStreams[basename($path)])){ $this->source=self::$sourceStreams[basename($path)]['stream']; @@ -45,7 +49,7 @@ class OC_CryptStream{ $this->path=$path; OCP\Util::writeLog('files_encryption','open encrypted '.$path. ' in '.$mode,OCP\Util::DEBUG); OC_FileProxy::$enabled=false;//disable fileproxies so we can open the source file - $this->source=OC_FileSystem::fopen($path,$mode); + $this->source=self::$rootView->fopen($path,$mode); OC_FileProxy::$enabled=true; if(!is_resource($this->source)){ OCP\Util::writeLog('files_encryption','failed to open '.$path,OCP\Util::ERROR); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 06f963fc981..9fd57c0f02b 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -59,7 +59,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{ * @return bool */ private static function isEncrypted($path){ - $metadata=OC_FileCache::getCached($path); + $metadata=OC_FileCache::getCached($path,''); return isset($metadata['encrypted']) and (bool)$metadata['encrypted']; } diff --git a/apps/files_encryption/tests/proxy.php b/apps/files_encryption/tests/proxy.php index 0450de82acb..f36b2193430 100644 --- a/apps/files_encryption/tests/proxy.php +++ b/apps/files_encryption/tests/proxy.php @@ -30,6 +30,9 @@ class Test_CryptProxy extends UnitTestCase { } public function testSimple(){ + $oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption','true'); + OCP\Config::setAppValue('files_encryption','enable_encryption','true'); + $file=OC::$SERVERROOT.'/3rdparty/MDB2.php'; $original=file_get_contents($file); @@ -42,5 +45,17 @@ class Test_CryptProxy extends UnitTestCase { $fromFile=OC_Filesystem::file_get_contents('/file'); $this->assertNotEqual($original,$stored); $this->assertEqual($original,$fromFile); + + $rootView=new OC_FilesystemView(''); + $view=new OC_FilesystemView('/'.OC_User::getUser()); + $userDir='/'.OC_User::getUser().'/files'; + + $fromFile=$rootView->file_get_contents($userDir.'/file'); + $this->assertEqual($original,$fromFile); + + $fromFile=$view->file_get_contents('files/file'); + $this->assertEqual($original,$fromFile); + + OCP\Config::setAppValue('files_encryption','enable_encryption',$oldConfig); } } |