From 0a7aa6e8cdbf96c3a54ea0a897eb5dfb8cd37c01 Mon Sep 17 00:00:00 2001
From: Florin Peter <github@florin-peter.de>
Date: Tue, 14 May 2013 22:32:39 +0200
Subject: [PATCH] fix for Allowed memory size of xx bytes exhausted while
 reading big files

---
 apps/files_encryption/lib/util.php | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php
index 0233804160..19c9cd72a1 100644
--- a/apps/files_encryption/lib/util.php
+++ b/apps/files_encryption/lib/util.php
@@ -480,13 +480,20 @@ class Util {
 	*/
 	public function isEncryptedPath( $path ) {
 	
-		// Disable encryption proxy so data retreived is in its 
+		// Disable encryption proxy so data retrieved is in its
 		// original form
+        $proxyStatus = \OC_FileProxy::$enabled;
 		\OC_FileProxy::$enabled = false;
-	
-		$data = $this->view->file_get_contents( $path );
-		
-		\OC_FileProxy::$enabled = true;
+
+        // we only need 24 byte from the last chunk
+        $data = '';
+		$handle = $this->view->fopen( $path, 'r' );
+        if(!fseek($handle, -24, SEEK_END)) {
+            $data = fgets($handle);
+        }
+
+        // re-enable proxy
+		\OC_FileProxy::$enabled = $proxyStatus;
 		
 		return Crypt::isCatfileContent( $data );
 	
-- 
GitLab