diff options
author | jknockaert <jasper@knockaert.nl> | 2015-05-20 09:35:20 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-05-21 14:15:26 +0200 |
commit | fb51880a4a5a2afb79b7aa1e9c041c300cf34e9c (patch) | |
tree | d210eca8fbedbfdbb23ad4e52ac0d223c914a01f | |
parent | aae9274210ad80e3c313d55999684c03f6e06b2c (diff) | |
download | nextcloud-server-fb51880a4a5a2afb79b7aa1e9c041c300cf34e9c.tar.gz nextcloud-server-fb51880a4a5a2afb79b7aa1e9c041c300cf34e9c.zip |
encrypted filesize calculation in flush()
-rw-r--r-- | lib/private/files/stream/encryption.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php index f2f5b9c9af7..7c8e6d4de83 100644 --- a/lib/private/files/stream/encryption.php +++ b/lib/private/files/stream/encryption.php @@ -412,7 +412,14 @@ class Encryption extends Wrapper { $encrypted = $this->encryptionModule->encrypt($this->cache); parent::stream_write($encrypted); $this->writeFlag = false; - $this->size = max($this->size, parent::stream_tell()); + // If the write concerns the last block then then update the encrypted filesize + // Note that the unencrypted pointer and filesize are NOT yet updated when flush() is called + // We recalculate the encrypted filesize as we do not know the context of calling flush() + if ((int)floor($this->unencryptedSize/$this->unencryptedBlockSize) === (int)floor($this->position/$this->unencryptedBlockSize)) { + $this->size = $this->util->getBlockSize() * (int)floor($this->unencryptedSize/$this->unencryptedBlockSize); + $this->size += strlen($encrypted); + $this->size += $this->headerSize; + } } // always empty the cache (otherwise readCache() will not fill it with the new block) $this->cache = ''; |