Skip to content

Commit

Permalink
Merge pull request #37394 from nextcloud/backport/36810/stable26
Browse files Browse the repository at this point in the history
[stable26] do onetime user setup before getting any mount from providers
  • Loading branch information
icewind1991 authored Apr 6, 2023
2 parents 3fcb416 + 9d58c51 commit 76350d8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/private/Files/SetupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,13 @@ public function setupForUser(IUser $user): void {
* part of the user setup that is run only once per user
*/
private function oneTimeUserSetup(IUser $user) {
if (in_array($user->getUID(), $this->setupUsers, true)) {
if ($this->isSetupStarted($user)) {
return;
}
$this->setupUsers[] = $user->getUID();

$this->setupRoot();

$this->eventLogger->start('fs:setup:user:onetime', 'Onetime filesystem for user');

$this->setupBuiltinWrappers();
Expand Down Expand Up @@ -319,11 +321,7 @@ private function afterUserFullySetup(IUser $user, array $previouslySetupProvider
* @throws \OC\ServerNotAvailableException
*/
private function setupForUserWith(IUser $user, callable $mountCallback): void {
$this->setupRoot();

if (!$this->isSetupStarted($user)) {
$this->oneTimeUserSetup($user);
}
$this->oneTimeUserSetup($user);

if ($this->lockdownManager->canAccessFilesystem()) {
$mountCallback();
Expand Down Expand Up @@ -422,9 +420,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
return;
}

if (!$this->isSetupStarted($user)) {
$this->oneTimeUserSetup($user);
}
$this->oneTimeUserSetup($user);

$this->eventLogger->start('fs:setup:user:path', "Setup $path filesystem for user");
$this->eventLogger->start('fs:setup:user:path:find', "Find mountpoint for $path");
Expand Down Expand Up @@ -513,6 +509,8 @@ public function setupForProvider(string $path, array $providers): void {

$this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for " . implode(', ', $providers));

$this->oneTimeUserSetup($user);

// home providers are always used
$providers = array_filter($providers, function (string $provider) {
return !is_subclass_of($provider, IHomeMountProvider::class);
Expand Down

0 comments on commit 76350d8

Please sign in to comment.