diff options
author | Bart Visscher <bartv@thisnet.nl> | 2012-05-04 17:04:11 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2012-05-04 17:04:11 +0200 |
commit | 1e471562268ff62c59708b724c22930bc1d01d95 (patch) | |
tree | 5b5125ec41e865fa009d51b4293042f6572067f4 /lib/filesystemview.php | |
parent | 71f9b1968e3d4decc4395db2a1555a872cbb2820 (diff) | |
parent | 07ff1e723ae4fa3a0297b168ef2262e01a0a5e50 (diff) | |
download | nextcloud-server-1e471562268ff62c59708b724c22930bc1d01d95.tar.gz nextcloud-server-1e471562268ff62c59708b724c22930bc1d01d95.zip |
Merge branch 'master' into tasks
Diffstat (limited to 'lib/filesystemview.php')
-rw-r--r-- | lib/filesystemview.php | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/filesystemview.php b/lib/filesystemview.php index 95873bd87cf..ac5a0a3bff5 100644 --- a/lib/filesystemview.php +++ b/lib/filesystemview.php @@ -136,15 +136,16 @@ class OC_FilesystemView { return $this->basicOperation('filesize',$path); } public function readfile($path){ + @ob_end_clean(); $handle=$this->fopen($path,'r'); if ($handle) { - $chunkSize = 1024*1024;// 1 MB chunks + $chunkSize = 8*1024;// 1 MB chunks while (!feof($handle)) { echo fread($handle, $chunkSize); - @ob_flush(); flush(); } - return $this->filesize($path); + $size=$this->filesize($path); + return $size; } return false; } @@ -174,11 +175,23 @@ class OC_FilesystemView { } public function file_put_contents($path,$data){ if(is_resource($data)){//not having to deal with streams in file_put_contents makes life easier + $exists=$this->file_exists($path); + $run=true; + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_create, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + } + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_write, array( OC_Filesystem::signal_param_path => $path, OC_Filesystem::signal_param_run => &$run)); + if(!$run){ + return false; + } $target=$this->fopen($path,'w'); if($target){ $count=OC_Helper::streamCopy($data,$target); fclose($target); fclose($data); + if(!$exists){ + OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_create, array( OC_Filesystem::signal_param_path => $path)); + } OC_Hook::emit( OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, array( OC_Filesystem::signal_param_path => $path)); return $count>0; }else{ |