Skip to content

Commit

Permalink
do onetime user setup before getting any mount from providers
Browse files Browse the repository at this point in the history
this fixes a race condition where wrappers weren't properly applied if when a mount provider creates the storage instance one mountpoint creation instead of lazily

Signed-off-by: Robin Appelman <robin@icewind.nl>
  • Loading branch information
icewind1991 committed Apr 6, 2023
1 parent 485f338 commit 44b9913
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 @@ -232,11 +232,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->setupBuiltinWrappers();

$prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
Expand Down Expand Up @@ -306,11 +308,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);

$this->eventLogger->start('setup_fs', 'Setup filesystem');

Expand Down Expand Up @@ -409,9 +407,7 @@ public function setupForPath(string $path, bool $includeChildren = false): void
return;
}

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

$mounts = [];
if (!in_array($cachedMount->getMountProvider(), $setupProviders)) {
Expand Down Expand Up @@ -488,6 +484,8 @@ public function setupForProvider(string $path, array $providers): void {
return;
}

$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 44b9913

Please sign in to comment.