]> source.dussan.org Git - nextcloud-server.git/commitdiff
rework the way file_put_contents is handeled
authorRobin Appelman <icewind@owncloud.com>
Sun, 12 Feb 2012 14:56:32 +0000 (15:56 +0100)
committerRobin Appelman <icewind@owncloud.com>
Tue, 21 Feb 2012 19:48:48 +0000 (20:48 +0100)
apps/files_encryption/lib/cryptstream.php
apps/files_encryption/lib/proxy.php

index 00dda7352b3f8c540d27b99b05e5db8c39dc1f30..97e0846187dbb32ed9ae2c56f6020d6c27122c4f 100644 (file)
@@ -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);
index 173aea785ecc7702cd7ba5c3a9701195833a79f9..be6ffa4f44d4f48b85f5ac264e87806720bd1a43 100644 (file)
@@ -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;
                }
        }