Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Files/Stream/Encryption.php')
-rw-r--r--lib/private/Files/Stream/Encryption.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/private/Files/Stream/Encryption.php b/lib/private/Files/Stream/Encryption.php
index 65d379c0289..3c884a99ae7 100644
--- a/lib/private/Files/Stream/Encryption.php
+++ b/lib/private/Files/Stream/Encryption.php
@@ -102,6 +102,9 @@ class Encryption extends Wrapper {
/** @var array */
protected $expectedContextProperties;
+ /** @var bool */
+ protected $fileUpdated;
+
public function __construct() {
$this->expectedContextProperties = array(
'source',
@@ -235,6 +238,7 @@ class Encryption extends Wrapper {
$this->position = 0;
$this->cache = '';
$this->writeFlag = false;
+ $this->fileUpdated = false;
$this->unencryptedBlockSize = $this->encryptionModule->getUnencryptedBlockSize($this->signed);
if (
@@ -313,7 +317,6 @@ class Encryption extends Wrapper {
}
public function stream_write($data) {
-
$length = 0;
// loop over $data to fit it in 6126 sized unencrypted blocks
while (isset($data[0])) {
@@ -333,6 +336,7 @@ class Encryption extends Wrapper {
// switch the writeFlag so flush() will write the block
$this->writeFlag = true;
+ $this->fileUpdated = true;
// determine the relative position in the current block
$blockPosition = ($this->position % $this->unencryptedBlockSize);
@@ -414,7 +418,18 @@ class Encryption extends Wrapper {
}
$this->encryptionStorage->updateUnencryptedSize($this->fullPath, $this->unencryptedSize);
}
- return parent::stream_close();
+ $result = parent::stream_close();
+
+ if ($this->fileUpdated) {
+ $cache = $this->storage->getCache();
+ $cacheEntry = $cache->get($this->internalPath);
+ if ($cacheEntry) {
+ $version = $cacheEntry['encryptedVersion'] + 1;
+ $cache->update($cacheEntry->getId(), ['encrypted' => $version, 'encryptedVersion' => $version]);
+ }
+ }
+
+ return $result;
}
/**