Skip to content

Commit bd2fc50

Browse files
Merge pull request #59172 from nextcloud/revert-58894-stable33-authoritative-share
[stable33] Revert "Stable33 authoritative share"
2 parents 60c2333 + 1d176c0 commit bd2fc50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+372
-1774
lines changed

apps/files/lib/Command/Mount/ListMounts.php

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88

99
namespace OCA\Files\Command\Mount;
1010

11-
use OC\Core\Command\Base;
1211
use OCP\Files\Config\ICachedMountInfo;
1312
use OCP\Files\Config\IMountProviderCollection;
1413
use OCP\Files\Config\IUserMountCache;
1514
use OCP\Files\Mount\IMountPoint;
1615
use OCP\IUserManager;
16+
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Input\InputArgument;
1818
use Symfony\Component\Console\Input\InputInterface;
19-
use Symfony\Component\Console\Input\InputOption;
2019
use Symfony\Component\Console\Output\OutputInterface;
2120

22-
class ListMounts extends Base {
21+
class ListMounts extends Command {
2322
public function __construct(
2423
private readonly IUserManager $userManager,
2524
private readonly IUserMountCache $userMountCache,
@@ -29,81 +28,52 @@ public function __construct(
2928
}
3029

3130
protected function configure(): void {
32-
parent::configure();
3331
$this
3432
->setName('files:mount:list')
3533
->setDescription('List of mounts for a user')
36-
->addArgument('user', InputArgument::REQUIRED, 'User to list mounts for')
37-
->addOption('cached-only', null, InputOption::VALUE_NONE, 'Only return cached mounts, prevents filesystem setup');
34+
->addArgument('user', InputArgument::REQUIRED, 'User to list mounts for');
3835
}
3936

4037
public function execute(InputInterface $input, OutputInterface $output): int {
4138
$userId = $input->getArgument('user');
42-
$cachedOnly = $input->getOption('cached-only');
4339
$user = $this->userManager->get($userId);
4440
if (!$user) {
4541
$output->writeln("<error>User $userId not found</error>");
4642
return 1;
4743
}
4844

49-
if ($cachedOnly) {
50-
$mounts = [];
51-
} else {
52-
$mounts = $this->mountProviderCollection->getMountsForUser($user);
53-
$mounts[] = $this->mountProviderCollection->getHomeMountForUser($user);
54-
}
55-
/** @var array<string, IMountPoint> $cachedByMountPoint */
56-
$mountsByMountPoint = array_combine(array_map(fn (IMountPoint $mount) => $mount->getMountPoint(), $mounts), $mounts);
45+
$mounts = $this->mountProviderCollection->getMountsForUser($user);
46+
$mounts[] = $this->mountProviderCollection->getHomeMountForUser($user);
47+
/** @var array<string, IMountPoint> $cachedByMountpoint */
48+
$mountsByMountpoint = array_combine(array_map(fn (IMountPoint $mount) => $mount->getMountPoint(), $mounts), $mounts);
5749
usort($mounts, fn (IMountPoint $a, IMountPoint $b) => $a->getMountPoint() <=> $b->getMountPoint());
5850

5951
$cachedMounts = $this->userMountCache->getMountsForUser($user);
6052
usort($cachedMounts, fn (ICachedMountInfo $a, ICachedMountInfo $b) => $a->getMountPoint() <=> $b->getMountPoint());
6153
/** @var array<string, ICachedMountInfo> $cachedByMountpoint */
62-
$cachedByMountPoint = array_combine(array_map(fn (ICachedMountInfo $mount) => $mount->getMountPoint(), $cachedMounts), $cachedMounts);
63-
64-
$format = $input->getOption('output');
54+
$cachedByMountpoint = array_combine(array_map(fn (ICachedMountInfo $mount) => $mount->getMountPoint(), $cachedMounts), $cachedMounts);
6555

66-
if ($format === self::OUTPUT_FORMAT_PLAIN) {
67-
foreach ($mounts as $mount) {
68-
$output->writeln('<info>' . $mount->getMountPoint() . '</info>: ' . $mount->getStorageId());
69-
if (isset($cachedByMountPoint[$mount->getMountPoint()])) {
70-
$cached = $cachedByMountPoint[$mount->getMountPoint()];
71-
$output->writeln("\t- provider: " . $cached->getMountProvider());
72-
$output->writeln("\t- storage id: " . $cached->getStorageId());
73-
$output->writeln("\t- root id: " . $cached->getRootId());
74-
} else {
75-
$output->writeln("\t<error>not registered</error>");
76-
}
56+
foreach ($mounts as $mount) {
57+
$output->writeln('<info>' . $mount->getMountPoint() . '</info>: ' . $mount->getStorageId());
58+
if (isset($cachedByMountpoint[$mount->getMountPoint()])) {
59+
$cached = $cachedByMountpoint[$mount->getMountPoint()];
60+
$output->writeln("\t- provider: " . $cached->getMountProvider());
61+
$output->writeln("\t- storage id: " . $cached->getStorageId());
62+
$output->writeln("\t- root id: " . $cached->getRootId());
63+
} else {
64+
$output->writeln("\t<error>not registered</error>");
7765
}
78-
foreach ($cachedMounts as $cachedMount) {
79-
if ($cachedOnly || !isset($mountsByMountPoint[$cachedMount->getMountPoint()])) {
80-
$output->writeln('<info>' . $cachedMount->getMountPoint() . '</info>:');
81-
if (!$cachedOnly) {
82-
$output->writeln("\t<error>registered but no longer provided</error>");
83-
}
84-
$output->writeln("\t- provider: " . $cachedMount->getMountProvider());
85-
$output->writeln("\t- storage id: " . $cachedMount->getStorageId());
86-
$output->writeln("\t- root id: " . $cachedMount->getRootId());
87-
}
66+
}
67+
foreach ($cachedMounts as $cachedMount) {
68+
if (!isset($mountsByMountpoint[$cachedMount->getMountPoint()])) {
69+
$output->writeln('<info>' . $cachedMount->getMountPoint() . '</info>:');
70+
$output->writeln("\t<error>registered but no longer provided</error>");
71+
$output->writeln("\t- provider: " . $cachedMount->getMountProvider());
72+
$output->writeln("\t- storage id: " . $cachedMount->getStorageId());
73+
$output->writeln("\t- root id: " . $cachedMount->getRootId());
8874
}
89-
} else {
90-
$cached = array_map(fn (ICachedMountInfo $cachedMountInfo) => [
91-
'mountpoint' => $cachedMountInfo->getMountPoint(),
92-
'provider' => $cachedMountInfo->getMountProvider(),
93-
'storage_id' => $cachedMountInfo->getStorageId(),
94-
'root_id' => $cachedMountInfo->getRootId(),
95-
], $cachedMounts);
96-
$provided = array_map(fn (IMountPoint $cachedMountInfo) => [
97-
'mountpoint' => $cachedMountInfo->getMountPoint(),
98-
'provider' => $cachedMountInfo->getMountProvider(),
99-
'storage_id' => $cachedMountInfo->getStorageId(),
100-
'root_id' => $cachedMountInfo->getStorageRootId(),
101-
], $mounts);
102-
$this->writeArrayInOutputFormat($input, $output, array_filter([
103-
'cached' => $cached,
104-
'provided' => $cachedOnly ? null : $provided,
105-
]));
10675
}
76+
10777
return 0;
10878
}
10979

apps/files/lib/Service/OwnershipTransferService.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use OCA\Files_External\Config\ConfigAdapter;
2020
use OCA\GroupFolders\Mount\GroupMountPoint;
2121
use OCP\Encryption\IManager as IEncryptionManager;
22-
use OCP\EventDispatcher\IEventDispatcher;
2322
use OCP\Files\Config\IHomeMountProvider;
2423
use OCP\Files\Config\IUserMountCache;
2524
use OCP\Files\File;
@@ -32,7 +31,6 @@
3231
use OCP\IUserManager;
3332
use OCP\L10N\IFactory;
3433
use OCP\Server;
35-
use OCP\Share\Events\ShareTransferredEvent;
3634
use OCP\Share\IManager as IShareManager;
3735
use OCP\Share\IShare;
3836
use Symfony\Component\Console\Helper\ProgressBar;
@@ -55,7 +53,6 @@ public function __construct(
5553
private IUserManager $userManager,
5654
private IFactory $l10nFactory,
5755
private IRootFolder $rootFolder,
58-
private IEventDispatcher $eventDispatcher,
5956
) {
6057
}
6158

@@ -570,23 +567,20 @@ private function restoreShares(
570567
} catch (\Throwable $e) {
571568
$output->writeln('<error>Could not restore share with id ' . $share->getId() . ':' . $e->getMessage() . ' : ' . $e->getTraceAsString() . '</error>');
572569
}
573-
$this->eventDispatcher->dispatchTyped(new ShareTransferredEvent($share));
574570
$progress->advance();
575571
}
576572
$progress->finish();
577573
$output->writeln('');
578574
}
579575

580-
private function transferIncomingShares(
581-
string $sourceUid,
576+
private function transferIncomingShares(string $sourceUid,
582577
string $destinationUid,
583578
array $sourceShares,
584579
array $destinationShares,
585580
OutputInterface $output,
586581
string $path,
587582
string $finalTarget,
588-
bool $move,
589-
): void {
583+
bool $move): void {
590584
$output->writeln('Restoring incoming shares ...');
591585
$progress = new ProgressBar($output, count($sourceShares));
592586
$prefix = "$destinationUid/files";
@@ -625,11 +619,8 @@ private function transferIncomingShares(
625619
if ($move) {
626620
continue;
627621
}
628-
$oldMountPoint = $this->getShareMountPoint($destinationUid, $share->getTarget());
629-
$newMountPoint = $this->getShareMountPoint($destinationUid, $shareTarget);
630622
$share->setTarget($shareTarget);
631623
$this->shareManager->moveShare($share, $destinationUid);
632-
$this->mountManager->moveMount($oldMountPoint, $newMountPoint);
633624
continue;
634625
}
635626
$this->shareManager->deleteShare($share);
@@ -647,11 +638,8 @@ private function transferIncomingShares(
647638
if ($move) {
648639
continue;
649640
}
650-
$oldMountPoint = $this->getShareMountPoint($destinationUid, $share->getTarget());
651-
$newMountPoint = $this->getShareMountPoint($destinationUid, $shareTarget);
652641
$share->setTarget($shareTarget);
653642
$this->shareManager->moveShare($share, $destinationUid);
654-
$this->mountManager->moveMount($oldMountPoint, $newMountPoint);
655643
continue;
656644
}
657645
} catch (NotFoundException $e) {
@@ -664,8 +652,4 @@ private function transferIncomingShares(
664652
$progress->finish();
665653
$output->writeln('');
666654
}
667-
668-
private function getShareMountPoint(string $uid, string $target): string {
669-
return '/' . $uid . '/files/' . trim($target, '/') . '/';
670-
}
671655
}

apps/files_sharing/composer/composer/autoload_classmap.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@
7070
'OCA\\Files_Sharing\\Listener\\LoadPublicFileRequestAuthListener' => $baseDir . '/../lib/Listener/LoadPublicFileRequestAuthListener.php',
7171
'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => $baseDir . '/../lib/Listener/LoadSidebarListener.php',
7272
'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => $baseDir . '/../lib/Listener/ShareInteractionListener.php',
73-
'OCA\\Files_Sharing\\Listener\\SharesUpdatedListener' => $baseDir . '/../lib/Listener/SharesUpdatedListener.php',
7473
'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => $baseDir . '/../lib/Listener/UserAddedToGroupListener.php',
75-
'OCA\\Files_Sharing\\Listener\\UserHomeSetupListener' => $baseDir . '/../lib/Listener/UserHomeSetupListener.php',
7674
'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => $baseDir . '/../lib/Listener/UserShareAcceptanceListener.php',
7775
'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => $baseDir . '/../lib/Middleware/OCSShareAPIMiddleware.php',
7876
'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => $baseDir . '/../lib/Middleware/ShareInfoMiddleware.php',
@@ -99,7 +97,6 @@
9997
'OCA\\Files_Sharing\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
10098
'OCA\\Files_Sharing\\ShareBackend\\File' => $baseDir . '/../lib/ShareBackend/File.php',
10199
'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php',
102-
'OCA\\Files_Sharing\\ShareRecipientUpdater' => $baseDir . '/../lib/ShareRecipientUpdater.php',
103100
'OCA\\Files_Sharing\\ShareTargetValidator' => $baseDir . '/../lib/ShareTargetValidator.php',
104101
'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php',
105102
'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php',

apps/files_sharing/composer/composer/autoload_static.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class ComposerStaticInitFiles_Sharing
8585
'OCA\\Files_Sharing\\Listener\\LoadPublicFileRequestAuthListener' => __DIR__ . '/..' . '/../lib/Listener/LoadPublicFileRequestAuthListener.php',
8686
'OCA\\Files_Sharing\\Listener\\LoadSidebarListener' => __DIR__ . '/..' . '/../lib/Listener/LoadSidebarListener.php',
8787
'OCA\\Files_Sharing\\Listener\\ShareInteractionListener' => __DIR__ . '/..' . '/../lib/Listener/ShareInteractionListener.php',
88-
'OCA\\Files_Sharing\\Listener\\SharesUpdatedListener' => __DIR__ . '/..' . '/../lib/Listener/SharesUpdatedListener.php',
8988
'OCA\\Files_Sharing\\Listener\\UserAddedToGroupListener' => __DIR__ . '/..' . '/../lib/Listener/UserAddedToGroupListener.php',
90-
'OCA\\Files_Sharing\\Listener\\UserHomeSetupListener' => __DIR__ . '/..' . '/../lib/Listener/UserHomeSetupListener.php',
9189
'OCA\\Files_Sharing\\Listener\\UserShareAcceptanceListener' => __DIR__ . '/..' . '/../lib/Listener/UserShareAcceptanceListener.php',
9290
'OCA\\Files_Sharing\\Middleware\\OCSShareAPIMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/OCSShareAPIMiddleware.php',
9391
'OCA\\Files_Sharing\\Middleware\\ShareInfoMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ShareInfoMiddleware.php',
@@ -114,7 +112,6 @@ class ComposerStaticInitFiles_Sharing
114112
'OCA\\Files_Sharing\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
115113
'OCA\\Files_Sharing\\ShareBackend\\File' => __DIR__ . '/..' . '/../lib/ShareBackend/File.php',
116114
'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php',
117-
'OCA\\Files_Sharing\\ShareRecipientUpdater' => __DIR__ . '/..' . '/../lib/ShareRecipientUpdater.php',
118115
'OCA\\Files_Sharing\\ShareTargetValidator' => __DIR__ . '/..' . '/../lib/ShareTargetValidator.php',
119116
'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php',
120117
'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php',

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use OCA\Files\Event\LoadSidebar;
1515
use OCA\Files_Sharing\Capabilities;
1616
use OCA\Files_Sharing\Config\ConfigLexicon;
17-
use OCA\Files_Sharing\Event\UserShareAccessUpdatedEvent;
1817
use OCA\Files_Sharing\External\Manager;
1918
use OCA\Files_Sharing\External\MountProvider as ExternalMountProvider;
2019
use OCA\Files_Sharing\Helper;
@@ -25,9 +24,7 @@
2524
use OCA\Files_Sharing\Listener\LoadPublicFileRequestAuthListener;
2625
use OCA\Files_Sharing\Listener\LoadSidebarListener;
2726
use OCA\Files_Sharing\Listener\ShareInteractionListener;
28-
use OCA\Files_Sharing\Listener\SharesUpdatedListener;
2927
use OCA\Files_Sharing\Listener\UserAddedToGroupListener;
30-
use OCA\Files_Sharing\Listener\UserHomeSetupListener;
3128
use OCA\Files_Sharing\Listener\UserShareAcceptanceListener;
3229
use OCA\Files_Sharing\Middleware\OCSShareAPIMiddleware;
3330
use OCA\Files_Sharing\Middleware\ShareInfoMiddleware;
@@ -49,19 +46,13 @@
4946
use OCP\Files\Events\BeforeDirectFileDownloadEvent;
5047
use OCP\Files\Events\BeforeZipCreatedEvent;
5148
use OCP\Files\Events\Node\BeforeNodeReadEvent;
52-
use OCP\Files\Events\UserHomeSetupEvent;
53-
use OCP\Group\Events\BeforeGroupDeletedEvent;
5449
use OCP\Group\Events\GroupChangedEvent;
5550
use OCP\Group\Events\GroupDeletedEvent;
5651
use OCP\Group\Events\UserAddedEvent;
57-
use OCP\Group\Events\UserRemovedEvent;
5852
use OCP\IConfig;
5953
use OCP\IDBConnection;
6054
use OCP\IGroup;
61-
use OCP\Share\Events\BeforeShareDeletedEvent;
6255
use OCP\Share\Events\ShareCreatedEvent;
63-
use OCP\Share\Events\ShareMovedEvent;
64-
use OCP\Share\Events\ShareTransferredEvent;
6556
use OCP\User\Events\UserChangedEvent;
6657
use OCP\User\Events\UserDeletedEvent;
6758
use OCP\Util;
@@ -120,18 +111,6 @@ function () use ($c) {
120111
// File request auth
121112
$context->registerEventListener(BeforeTemplateRenderedEvent::class, LoadPublicFileRequestAuthListener::class);
122113

123-
// Update mounts
124-
$context->registerEventListener(ShareCreatedEvent::class, SharesUpdatedListener::class);
125-
$context->registerEventListener(BeforeShareDeletedEvent::class, SharesUpdatedListener::class);
126-
$context->registerEventListener(ShareTransferredEvent::class, SharesUpdatedListener::class);
127-
$context->registerEventListener(UserAddedEvent::class, SharesUpdatedListener::class);
128-
$context->registerEventListener(UserRemovedEvent::class, SharesUpdatedListener::class);
129-
$context->registerEventListener(BeforeGroupDeletedEvent::class, SharesUpdatedListener::class);
130-
$context->registerEventListener(GroupDeletedEvent::class, SharesUpdatedListener::class);
131-
$context->registerEventListener(UserShareAccessUpdatedEvent::class, SharesUpdatedListener::class);
132-
$context->registerEventListener(ShareMovedEvent::class, SharesUpdatedListener::class);
133-
$context->registerEventListener(UserHomeSetupEvent::class, UserHomeSetupListener::class);
134-
135114
$context->registerConfigLexicon(ConfigLexicon::class);
136115
}
137116

apps/files_sharing/lib/Config/ConfigLexicon.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class ConfigLexicon implements ILexicon {
2424
public const SHOW_FEDERATED_AS_INTERNAL = 'show_federated_shares_as_internal';
2525
public const SHOW_FEDERATED_TO_TRUSTED_AS_INTERNAL = 'show_federated_shares_to_trusted_servers_as_internal';
2626
public const EXCLUDE_RESHARE_FROM_EDIT = 'shareapi_exclude_reshare_from_edit';
27-
public const UPDATE_CUTOFF_TIME = 'update_cutoff_time';
28-
public const USER_NEEDS_SHARE_REFRESH = 'user_needs_share_refresh';
2927

3028
public function getStrictness(): Strictness {
3129
return Strictness::IGNORE;
@@ -36,14 +34,10 @@ public function getAppConfigs(): array {
3634
new Entry(self::SHOW_FEDERATED_AS_INTERNAL, ValueType::BOOL, false, 'shows federated shares as internal shares', true),
3735
new Entry(self::SHOW_FEDERATED_TO_TRUSTED_AS_INTERNAL, ValueType::BOOL, false, 'shows federated shares to trusted servers as internal shares', true),
3836
new Entry(self::EXCLUDE_RESHARE_FROM_EDIT, ValueType::BOOL, false, 'Exclude reshare permission from "Allow editing" bundled permissions'),
39-
40-
new Entry(self::UPDATE_CUTOFF_TIME, ValueType::FLOAT, 3.0, 'For how how long do we update the share data immediately before switching to only marking the user'),
4137
];
4238
}
4339

4440
public function getUserConfigs(): array {
45-
return [
46-
new Entry(self::USER_NEEDS_SHARE_REFRESH, ValueType::BOOL, false, 'whether a user needs to have the receiving share data refreshed for possible changes'),
47-
];
41+
return [];
4842
}
4943
}

0 commit comments

Comments
 (0)