summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/storage.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions/lib/storage.php')
-rw-r--r--apps/files_versions/lib/storage.php22
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/files_versions/lib/storage.php b/apps/files_versions/lib/storage.php
index b4111d88e30..a213ea75238 100644
--- a/apps/files_versions/lib/storage.php
+++ b/apps/files_versions/lib/storage.php
@@ -191,12 +191,7 @@ class Storage {
$mtime = $users_view->filemtime('files/' . $filename);
$users_view->copy('files/' . $filename, 'files_versions/' . $filename . '.v' . $mtime);
// call getFileInfo to enforce a file cache entry for the new version
- $newFileInfo = $users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime);
-
- // Keep the "encrypted" value of the original file
- $oldVersion = $files_view->getFileInfo($filename)->getEncryptedVersion();
- $cache = $newFileInfo->getStorage()->getCache();
- $cache->update($newFileInfo->getId(), ['encrypted' => $oldVersion, 'encryptedVersion' => $oldVersion]);
+ $users_view->getFileInfo('files_versions/' . $filename . '.v' . $mtime);
}
}
@@ -331,15 +326,22 @@ class Storage {
//first create a new version
$version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename);
- if ( !$users_view->file_exists($version)) {
-
+ if (!$users_view->file_exists($version)) {
$users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename));
-
$versionCreated = true;
}
+ $fileToRestore = 'files_versions' . $filename . '.v' . $revision;
+
+ // Restore encrypted version of the old file for the newly restored file
+ // This has to happen manually here since the file is manually copied below
+ $oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
+ $newFileInfo = $files_view->getFileInfo($filename);
+ $cache = $newFileInfo->getStorage()->getCache();
+ $cache->update($newFileInfo->getId(), ['encrypted' => $oldVersion, 'encryptedVersion' => $oldVersion]);
+
// rollback
- if (self::copyFileContents($users_view, 'files_versions' . $filename . '.v' . $revision, 'files' . $filename)) {
+ if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
$files_view->touch($file, $revision);
Storage::scheduleExpire($uid, $file);
\OC_Hook::emit('\OCP\Versions', 'rollback', array(