diff --git a/lib/Crypto/Encryption.php b/lib/Crypto/Encryption.php index 59ca46b1..6cd65557 100644 --- a/lib/Crypto/Encryption.php +++ b/lib/Crypto/Encryption.php @@ -189,7 +189,23 @@ public function begin($path, $user, $mode, array $header, array $accessList) { // always use the version from the original file, also part files // need to have a correct version number if they get moved over to the // final location - $this->version = (int)$this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); + if (\OC::$server->getSession()->exists('renameFile')) { + list($sourcePath,$targetPath) = \OC::$server->getSession()->get('renameFile'); + /* + * Rename triggered. So if the path and targetpath are same use + * sourcepath's version number. Else use path's version, because that's + * sourcepath. + */ + if ( $path === $targetPath) { + $this->version = $this->keyManager->getVersion($sourcePath, new View()); + } else { + $this->version = (int)$this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); + } + } else { + //If not rename then use path's current version. + $this->version = (int)$this->keyManager->getVersion($this->stripPartFileExtension($path), new View()); + } + if ( $mode === 'w'