Skip to content

Commit 2d74a75

Browse files
committed
refactor(files_sharing): apply DRY in MountProvider
Signed-off-by: Salvatore Martire <[email protected]>
1 parent 111d939 commit 2d74a75

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

apps/files_sharing/lib/MountProvider.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,8 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
7979
$newMaxValidatedShare = $maxValidatedShare;
8080

8181
foreach ($superShares as $share) {
82+
[$parentShare, $groupedShares] = $share;
8283
try {
83-
/** @var IShare $parentShare */
84-
$parentShare = $share[0];
85-
8684
if ($parentShare->getStatus() !== IShare::STATUS_ACCEPTED
8785
&& ($parentShare->getShareType() === IShare::TYPE_GROUP
8886
|| $parentShare->getShareType() === IShare::TYPE_USERGROUP
@@ -92,7 +90,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
9290

9391
$owner = $parentShare->getShareOwner();
9492
if (!isset($ownerViews[$owner])) {
95-
$ownerViews[$owner] = new View('/' . $parentShare->getShareOwner() . '/files');
93+
$ownerViews[$owner] = new View('/' . $owner . '/files');
9694
}
9795
$shareId = (int)$parentShare->getId();
9896
$mount = new SharedMount(
@@ -103,7 +101,7 @@ public function getMountsForUser(IUser $user, IStorageFactory $loader) {
103101
// parent share
104102
'superShare' => $parentShare,
105103
// children/component of the superShare
106-
'groupedShares' => $share[1],
104+
'groupedShares' => $groupedShares,
107105
'ownerView' => $ownerViews[$owner],
108106
'sharingDisabledForUser' => $sharingDisabledForUser
109107
],

build/psalm-baseline.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,11 +1685,11 @@
16851685
</file>
16861686
<file src="apps/files_sharing/lib/MountProvider.php">
16871687
<InternalClass>
1688-
<code><![CDATA[new View('/' . $parentShare->getShareOwner() . '/files')]]></code>
1688+
<code><![CDATA[new View('/' . $owner . '/files')]]></code>
16891689
<code><![CDATA[new View('/' . $userId . '/files')]]></code>
16901690
</InternalClass>
16911691
<InternalMethod>
1692-
<code><![CDATA[new View('/' . $parentShare->getShareOwner() . '/files')]]></code>
1692+
<code><![CDATA[new View('/' . $owner . '/files')]]></code>
16931693
<code><![CDATA[new View('/' . $userId . '/files')]]></code>
16941694
</InternalMethod>
16951695
</file>

0 commit comments

Comments
 (0)