]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix saved file size for uploaded files
authorRobin Appelman <icewind@owncloud.com>
Thu, 21 Jun 2012 16:07:56 +0000 (18:07 +0200)
committerRobin Appelman <icewind@owncloud.com>
Thu, 21 Jun 2012 16:07:56 +0000 (18:07 +0200)
apps/files_encryption/lib/cryptstream.php
lib/filecache.php

index 901e8cccbfb6364544cfd0aab930d6265f7fbe8b..9949c1896a8d3313d49b4c8f932a17bc0028cf00 100644 (file)
@@ -115,8 +115,9 @@ class OC_CryptStream{
                        $data=substr($block,0,$currentPos%8192).$data;
                        fseek($this->source,-($currentPos%8192),SEEK_CUR);
                }
-               while(strlen($data)>0){
-                       if(strlen($data)<8192){
+               $currentPos=ftell($this->source);
+               while($remainingLength=strlen($data)>0){
+                       if($remainingLength<8192){
                                $this->writeCache=$data;
                                $data='';
                        }else{
@@ -125,8 +126,7 @@ class OC_CryptStream{
                                $data=substr($data,8192);
                        }
                }
-               $currentPos=ftell($this->source);
-               $this->size=max($this->size,$currentPos);
+               $this->size=max($this->size,$currentPos+$length);
                return $length;
        }
 
index 1d22bb34dfc247e97e5cf8d4febc37aae6b82c67..da9baa020a2c5e28b9cb72452c8d1ea70e4262ed 100644 (file)
@@ -91,14 +91,14 @@ class OC_FileCache{
                        $data=array_merge(OC_FileCache::$savedData[$path],$data);
                        unset(OC_FileCache::$savedData[$path]);
                }
-               if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it
-                       self::$savedData[$path]=$data;
-                       return;
-               }
                if($id!=-1){
                        self::update($id,$data);
                        return;
                }
+               if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it
+                       self::$savedData[$path]=$data;
+                       return;
+               }
                if(!isset($data['encrypted'])){
                        $data['encrypted']=false;
                }