summaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_versions/lib')
-rw-r--r--apps/files_versions/lib/Storage.php17
-rw-r--r--apps/files_versions/lib/Versions/LegacyVersionsBackend.php2
2 files changed, 8 insertions, 11 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php
index c63a3dba403..8df98d087d8 100644
--- a/apps/files_versions/lib/Storage.php
+++ b/apps/files_versions/lib/Storage.php
@@ -52,6 +52,7 @@ use OCA\Files_Versions\Command\Expire;
use OCA\Files_Versions\Events\CreateVersionEvent;
use OCA\Files_Versions\Versions\IVersionManager;
use OCP\Files\NotFoundException;
+use OCP\IUser;
use OCP\Lock\ILockingProvider;
use OCP\User;
@@ -327,20 +328,16 @@ class Storage {
* @param int $revision revision timestamp
* @return bool
*/
- public static function rollback($file, $revision) {
+ public static function rollback(string $file, int $revision, IUser $user) {
// add expected leading slash
- $file = '/' . ltrim($file, '/');
- list($uid, $filename) = self::getUidAndFilename($file);
- if ($uid === null || trim($filename, '/') === '') {
- return false;
- }
+ $filename = '/' . ltrim($file, '/');
// Fetch the userfolder to trigger view hooks
- $userFolder = \OC::$server->getUserFolder($uid);
+ $userFolder = \OC::$server->getUserFolder($user->getUID());
- $users_view = new View('/'.$uid);
- $files_view = new View('/'. User::getUser().'/files');
+ $users_view = new View('/'.$user->getUID());
+ $files_view = new View('/'. $user->getUID().'/files');
$versionCreated = false;
@@ -376,7 +373,7 @@ class Storage {
// rollback
if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
$files_view->touch($file, $revision);
- Storage::scheduleExpire($uid, $file);
+ Storage::scheduleExpire($user->getUID(), $file);
$node = $userFolder->get($file);
diff --git a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
index b441a16ca82..db8530d1303 100644
--- a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
+++ b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
@@ -97,7 +97,7 @@ class LegacyVersionsBackend implements IVersionBackend {
}
public function rollback(IVersion $version) {
- return Storage::rollback($version->getVersionPath(), $version->getRevisionId());
+ return Storage::rollback($version->getVersionPath(), $version->getRevisionId(), $version->getUser());
}
private function getVersionFolder(IUser $user): Folder {