summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/files/stream/encryption.php29
1 files changed, 16 insertions, 13 deletions
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php
index 910357eef45..936bcb71e71 100644
--- a/lib/private/files/stream/encryption.php
+++ b/lib/private/files/stream/encryption.php
@@ -221,15 +221,28 @@ class Encryption extends Wrapper {
|| $mode === 'w+'
|| $mode === 'wb'
|| $mode === 'wb+'
+ || $mode === 'r+'
+ || $mode === 'rb+'
) {
- // We're writing a new file so start write counter with 0 bytes
- $this->unencryptedSize = 0;
- $this->size = 0;
$this->readOnly = false;
} else {
$this->readOnly = true;
}
+ if (
+ $mode === 'w'
+ || $mode === 'w+'
+ || $mode === 'wb'
+ || $mode === 'wb+'
+ ) {
+ // We're writing a new file so start write counter with 0 bytes
+ $this->unencryptedSize = 0;
+ $this->writeHeader();
+ $this->size = $this->util->getHeaderSize();
+ } else {
+ parent::stream_read($this->util->getHeaderSize());
+ }
+
$sharePath = $this->fullPath;
if (!$this->storage->file_exists($this->internalPath)) {
$sharePath = dirname($sharePath);
@@ -250,11 +263,6 @@ class Encryption extends Wrapper {
$result = '';
- // skip the header if we read the file from the beginning
- if ($this->position === 0) {
- parent::stream_read($this->util->getHeaderSize());
- }
-
// $count = min($count, $this->unencryptedSize - $this->position);
while ($count > 0) {
$remainingLength = $count;
@@ -281,11 +289,6 @@ class Encryption extends Wrapper {
public function stream_write($data) {
- if ($this->position === 0) {
- $this->writeHeader();
- $this->size = $this->util->getHeaderSize();
- }
-
$length = 0;
// loop over $data to fit it in 6126 sized unencrypted blocks
while (strlen($data) > 0) {