From 56de98ed8cb74cc197d5b7cecdc519c2c267e3a5 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 21 Jun 2012 18:07:56 +0200 Subject: [PATCH] fix saved file size for uploaded files --- apps/files_encryption/lib/cryptstream.php | 8 ++++---- lib/filecache.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/files_encryption/lib/cryptstream.php b/apps/files_encryption/lib/cryptstream.php index 4ef7d1e08b..e002053756 100644 --- a/apps/files_encryption/lib/cryptstream.php +++ b/apps/files_encryption/lib/cryptstream.php @@ -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; } diff --git a/lib/filecache.php b/lib/filecache.php index d5458834e0..e3bcc7d000 100644 --- a/lib/filecache.php +++ b/lib/filecache.php @@ -72,14 +72,14 @@ class OC_FileCache{ $data=array_merge(OC_FileCache_Cached::$savedData[$path],$data); unset(OC_FileCache_Cached::$savedData[$path]); } - if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it - OC_FileCache_Cached::$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 + OC_FileCache_Cached::$savedData[$path]=$data; + return; + } if(!isset($data['encrypted'])){ $data['encrypted']=false; }