diff options
author | jknockaert <jasper@knockaert.nl> | 2015-05-22 22:13:27 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2015-05-26 10:22:52 +0200 |
commit | a577e723b0e46f5afcfd1cbee27215e832340509 (patch) | |
tree | ff2ef3cfe266c7c975d4a4f05027c7f74f5c8bf8 /lib/private/files/stream | |
parent | bf6151e7994d50eeab65a50078d3c6a7c79a47cf (diff) | |
download | nextcloud-server-a577e723b0e46f5afcfd1cbee27215e832340509.tar.gz nextcloud-server-a577e723b0e46f5afcfd1cbee27215e832340509.zip |
flush() comments + perf opt
Diffstat (limited to 'lib/private/files/stream')
-rw-r--r-- | lib/private/files/stream/encryption.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/private/files/stream/encryption.php b/lib/private/files/stream/encryption.php index dfffad3450a..22d230e7c86 100644 --- a/lib/private/files/stream/encryption.php +++ b/lib/private/files/stream/encryption.php @@ -412,14 +412,16 @@ class Encryption extends Wrapper { // we are handling that separately here and we don't want to // get into an infinite loop $encrypted = $this->encryptionModule->encrypt($this->cache); - parent::stream_write($encrypted); + $bytesWritten = parent::stream_write($encrypted); $this->writeFlag = false; - // If the write concerns the last block then then update the encrypted filesize + // Check whether the write concerns the last block + // If so 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); + $completeBlocksInFile=(int)floor($this->unencryptedSize/$this->unencryptedBlockSize); + if ($completeBlocksInFile === (int)floor($this->position/$this->unencryptedBlockSize)) { + $this->size = $this->util->getBlockSize() * $completeBlocksInFile; + $this->size += $bytesWritten; $this->size += $this->headerSize; } } |