Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable22] always use the default fs owner when storing versions #33975

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions apps/files_versions/lib/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OC_User;
use OC\Files\Filesystem;
use OC\Files\View;
use OCA\Files_Sharing\SharedMount;
use OCA\Files_Versions\AppInfo\Application;
use OCA\Files_Versions\Command\Expire;
use OCA\Files_Versions\Events\CreateVersionEvent;
Expand Down Expand Up @@ -172,9 +173,13 @@ public static function store($filename) {
return false;
}

[$uid, $filename] = self::getUidAndFilename($filename);
// since hook paths are always relative to the "default filesystem view"
// we always use the owner from there to get the full node
$uid = Filesystem::getView()->getOwner('');

$files_view = new View('/'.$uid .'/files');
/** @var IRootFolder $rootFolder */
$rootFolder = \OC::$server->get(IRootFolder::class);

Check failure

Code scanning / Psalm

UndefinedDocblockClass

Docblock-defined class, interface or enum named OCA\Files_Versions\IRootFolder does not exist

Check failure

Code scanning / Psalm

UndefinedClass

Class, interface or enum named OCA\Files_Versions\IRootFolder does not exist
$userFolder = $rootFolder->getUserFolder($uid);

Check failure

Code scanning / Psalm

UndefinedDocblockClass

Docblock-defined class, interface or enum named OCA\Files_Versions\IRootFolder does not exist

$eventDispatcher = \OC::$server->getEventDispatcher();
$fileInfo = $files_view->getFileInfo($filename);
Expand All @@ -189,7 +194,13 @@ public static function store($filename) {
}

// no use making versions for empty files
if ($fileInfo->getSize() === 0) {
if ($file->getSize() === 0) {

Check failure

Code scanning / Psalm

UndefinedVariable

Cannot find referenced variable $file
return false;
}

$event = new CreateVersionEvent($file);

Check failure

Code scanning / Psalm

UndefinedVariable

Cannot find referenced variable $file
$eventDispatcher->dispatch('OCA\Files_Versions::createVersion', $event);

Check failure

Code scanning / Psalm

TooManyArguments

Too many arguments for method Symfony\Contracts\EventDispatcher\EventDispatcherInterface::dispatch - saw 2

Check failure

Code scanning / Psalm

InvalidArgument

Argument 1 of Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch expects object, "OCA\\Files_Versions::createVersion" provided
if ($event->shouldCreateVersion() === false) {
return false;
}

Expand All @@ -198,7 +209,7 @@ public static function store($filename) {
$userManager = \OC::$server->getUserManager();
$user = $userManager->get($uid);

$versionManager->createVersion($user, $fileInfo);
$versionManager->createVersion($file->getOwner(), $file);
}


Expand Down