]> source.dussan.org Git - nextcloud-server.git/commitdiff
don't call getFileInfo() to avoid to open the same file twice
authorBjoern Schiessle <schiessle@owncloud.com>
Mon, 31 Mar 2014 10:43:38 +0000 (12:43 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Mon, 31 Mar 2014 13:29:16 +0000 (15:29 +0200)
apps/files_encryption/lib/stream.php

index 58ac03373a737bc2136a5cde4fad3b385114b1fc..1a163db887c4bbad61520a9e3c5e74dca195d482 100644 (file)
@@ -568,21 +568,25 @@ class Stream {
                        // part file.
                        $path = Helper::stripPartialFileExtension($this->rawPath);
 
-                       // get file info
-                       $fileInfo = $this->rootView->getFileInfo($path);
-                       if ($fileInfo) {
-                               // set encryption data
-                               $fileInfo['encrypted'] = true;
-                               $fileInfo['size'] = $this->size;
-                               $fileInfo['unencrypted_size'] = $this->unencryptedSize;
-
-                               // set fileinfo
-                               $this->rootView->putFileInfo($path, $fileInfo);
-                       }
+                       $fileInfo = array(
+                               'encrypted' => true,
+                               'size' => $this->size,
+                               'unencrypted_size' => $this->unencryptedSize,
+                       );
+
+                       // set fileinfo
+                       $this->rootView->putFileInfo($path, $fileInfo);
 
                }
 
-               return fclose($this->handle);
+               $result = fclose($this->handle);
+
+               if ($result === false) {
+                       \OCP\Util::writeLog('Encryption library', 'Could not close stream, file could be corrupted', \OCP\Util::FATAL);
+               }
+
+               return $result;
+
        }
 
 }