]> source.dussan.org Git - nextcloud-server.git/commitdiff
Using stream_get_contents in file_get_contents implementation + close handle
authorThomas Müller <thomas.mueller@tmit.eu>
Thu, 2 Apr 2015 14:18:10 +0000 (16:18 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 7 Apr 2015 11:30:31 +0000 (13:30 +0200)
lib/private/files/storage/wrapper/encryption.php

index 58d963613aa54749b331d6671d3cf178d7c5892b..3ea3b987d4c4ad79d1d60273c941d75adb018ec3 100644 (file)
@@ -112,23 +112,18 @@ class Encryption extends Wrapper {
         */
        public function file_get_contents($path) {
 
-               $data = null;
                $encryptionModule = $this->getEncryptionModule($path);
 
                if ($encryptionModule) {
-
-                       $handle = $this->fopen($path, 'r');
-
-                       if (is_resource($handle)) {
-                               while (!feof($handle)) {
-                                       $data .= fread($handle, $this->util->getBlockSize());
-                               }
+                       $handle = $this->fopen($path, "r");
+                       if (!$handle) {
+                               return false;
                        }
-               } else {
-                       $data = $this->storage->file_get_contents($path);
+                       $data = stream_get_contents($handle);
+                       fclose($handle);
+                       return $data;
                }
-
-               return $data;
+               return $this->storage->file_get_contents($path);
        }
 
        /**