]> source.dussan.org Git - nextcloud-server.git/commitdiff
Check file handle exists before trying to read file
authorMichael Gapczynski <GapczynskiM@gmail.com>
Sun, 1 Apr 2012 06:38:26 +0000 (02:38 -0400)
committerMichael Gapczynski <GapczynskiM@gmail.com>
Sun, 1 Apr 2012 06:38:26 +0000 (02:38 -0400)
lib/filesystemview.php

index 39e47975b284094c0f8bbbb4f68ca787dafd8eb8..a3736f1976c3e1311451c8ade801a334ec5afe40 100644 (file)
@@ -137,13 +137,16 @@ class OC_FilesystemView {
        }
        public function readfile($path){
                $handle=$this->fopen($path,'r');
-               $chunkSize = 1024*1024;// 1 MB chunks
-               while (!feof($handle)) {
-                       echo fread($handle, $chunkSize);
-                       @ob_flush();
-                       flush();
+               if ($handle) {
+                       $chunkSize = 1024*1024;// 1 MB chunks
+                       while (!feof($handle)) {
+                               echo fread($handle, $chunkSize);
+                               @ob_flush();
+                               flush();
+                       }
+                       return $this->filesize($path);
                }
-               return $this->filesize($path);
+               return false;
        }
        public function is_readable($path){
                return $this->basicOperation('is_readable',$path);