summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-02-12 15:56:32 +0100
committerRobin Appelman <icewind@owncloud.com>2012-02-21 20:48:48 +0100
commit6a8364c3ffeb9d6227f141ae77ba317a1afbfdf6 (patch)
treeadc7d6494a32ca97203a225505c9de6cc6725aed
parent95459d068e47b83ed13348da3e1d03d062209e41 (diff)
downloadnextcloud-server-6a8364c3ffeb9d6227f141ae77ba317a1afbfdf6.tar.gz
nextcloud-server-6a8364c3ffeb9d6227f141ae77ba317a1afbfdf6.zip
rework the way file_put_contents is handeled
-rw-r--r--apps/files_encryption/lib/cryptstream.php1
-rw-r--r--apps/files_encryption/lib/proxy.php14
2 files changed, 5 insertions, 10 deletions
diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php
index 00dda7352b3..97e0846187d 100644
--- a/apps/files_encryption/lib/cryptstream.php
+++ b/apps/files_encryption/lib/cryptstream.php
@@ -90,6 +90,7 @@ class OC_CryptStream{
}
public function stream_write($data){
+ error_log('write to '. $this->path);
$length=strlen($data);
$written=0;
$currentPos=ftell($this->source);
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 173aea785ec..be6ffa4f44d 100644
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -70,19 +70,13 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
public function preFile_put_contents($path,&$data){
if(self::shouldEncrypt($path)){
- $exists=OC_Filesystem::file_exists($path);
- $target=fopen('crypt://'.$path,'w');
if (is_resource($data)) {
- while(!feof($data)){
- fwrite($target,fread($data,8192));
- }
+ $id=md5($path);
+ OC_CryptStream::$sourceStreams[$id]=array('path'=>$path,'stream'=>$data);
+ $data=fopen('crypt://streams/'.$id,'r');
}else{
- fwrite($target,$data);
+ $data=OC_Crypt::blockEncrypt($data);
}
- //fake the normal hooks
- OC_Hook::emit( 'OC_Filesystem', 'post_create', array( 'path' => $path));
- OC_Hook::emit( 'OC_Filesystem', 'post_write', array( 'path' => $path));
- return false;
}
}