diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-02-27 12:20:37 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-02-27 12:20:37 +0100 |
commit | d8d4420f227588acedb50918a1b794a2c68a7ade (patch) | |
tree | 6ea8ee6c75353b2308c229530749cc2641925462 | |
parent | cef230c141897f587dd732860cca6568fd6edc2c (diff) | |
download | nextcloud-server-d8d4420f227588acedb50918a1b794a2c68a7ade.tar.gz nextcloud-server-d8d4420f227588acedb50918a1b794a2c68a7ade.zip |
some cleanup in filestorage
-rw-r--r-- | lib/filestorage/local.php | 4 | ||||
-rw-r--r-- | lib/filesystemview.php | 16 |
2 files changed, 5 insertions, 15 deletions
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php index 7d889fbce58..8acfe504cb2 100644 --- a/lib/filestorage/local.php +++ b/lib/filestorage/local.php @@ -96,9 +96,7 @@ class OC_Filestorage_Local extends OC_Filestorage{ $source=substr($path1,strrpos($path1,'/')+1); $path2.=$source; } - if($return=copy($this->datadir.$path1,$this->datadir.$path2)){ - } - return $return; + return copy($this->datadir.$path1,$this->datadir.$path2); } public function fopen($path,$mode){ if($return=fopen($this->datadir.$path,$mode)){ diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 9f0a88f8ab0..b014c3272f7 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -173,13 +173,11 @@ class OC_FilesystemView { if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier $target=$this->fopen($path,'w'); if($target){ - while(!feof($data)){ - fwrite($target,fread($data,8192)); - } + $count=OC_Helper::streamCopy($data,$target); fclose($target); fclose($data); OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path)); - return true; + return $count>0; }else{ return false; } @@ -204,9 +202,7 @@ class OC_FilesystemView { }else{ $source=$this->fopen($path1,'r'); $target=$this->fopen($path2,'w'); - while (!feof($source)){ - fwrite($target,fread($source,8192)); - } + $count=OC_Helper::streamCopy($data,$target); $storage1=$this->getStorage($path1); $storage1->unlink($this->getInternalPath($path1)); } @@ -236,11 +232,7 @@ class OC_FilesystemView { }else{ $source=$this->fopen($path1,'r'); $target=$this->fopen($path2,'w'); - if($target and $source){ - while (!feof($source)){ - fwrite($target,fread($source,8192)); - } - } + $count=OC_Helper::streamCopy($data,$target); } OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_copy, array( OC_Filesystem::signal_param_oldpath => $path1 , OC_Filesystem::signal_param_newpath=>$path2)); if(!$exists){ |