From 02404a6a8cd07ca79add601deaefe3b4940eddfa Mon Sep 17 00:00:00 2001
From: jknockaert <jasper@knockaert.nl>
Date: Thu, 2 Apr 2015 14:52:54 +0200
Subject: [PATCH] Fixing encryption stream wrapper seek - thanks  @jknockaert

---
 lib/private/files/stream/encryption.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index fcc9984500..fdfe73d99c 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -362,8 +362,11 @@ class Encryption extends Wrapper {
 		$newFilePosition = floor($newPosition / $this->unencryptedBlockSize)
 			* $this->util->getBlockSize() + $this->util->getHeaderSize();
 
+		$oldFilePosition = parent::stream_tell();
 		if (parent::stream_seek($newFilePosition)) {
+			parent::stream_seek($oldFilePosition);
 			$this->flush();
+			parent::stream_seek($newFilePosition);
 			$this->position = $newPosition;
 			$return = true;
 		}
-- 
GitLab