Skip to content

Commit 8fef987

Browse files
come-ncbackportbot[bot]
authored andcommitted
fix: Use default share folder of the user on share accept
Signed-off-by: Côme Chilliet <[email protected]>
1 parent 09b7e8b commit 8fef987

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

lib/private/Share20/DefaultShareProvider.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use OCP\Files\Folder;
4545
use OCP\Files\IRootFolder;
4646
use OCP\Files\Node;
47+
use OCP\IConfig;
4748
use OCP\IDBConnection;
4849
use OCP\IGroupManager;
4950
use OCP\IURLGenerator;
@@ -105,6 +106,7 @@ public function __construct(
105106
IURLGenerator $urlGenerator,
106107
ITimeFactory $timeFactory,
107108
private IManager $shareManager,
109+
private IConfig $config,
108110
) {
109111
$this->dbConn = $connection;
110112
$this->userManager = $userManager;
@@ -547,6 +549,15 @@ public function deleteFromSelf(IShare $share, $recipient) {
547549
protected function createUserSpecificGroupShare(IShare $share, string $recipient): int {
548550
$type = $share->getNodeType();
549551

552+
$shareFolder = $this->config->getSystemValue('share_folder', '/');
553+
$allowCustomShareFolder = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true);
554+
if ($allowCustomShareFolder) {
555+
$shareFolder = $this->config->getUserValue($recipient, Application::APP_ID, 'share_folder', $shareFolder);
556+
}
557+
558+
$target = $shareFolder . '/' . $share->getNode()->getName();
559+
$target = \OC\Files\Filesystem::normalizePath($target);
560+
550561
$qb = $this->dbConn->getQueryBuilder();
551562
$qb->insert('share')
552563
->values([
@@ -558,7 +569,7 @@ protected function createUserSpecificGroupShare(IShare $share, string $recipient
558569
'item_type' => $qb->createNamedParameter($type),
559570
'item_source' => $qb->createNamedParameter($share->getNodeId()),
560571
'file_source' => $qb->createNamedParameter($share->getNodeId()),
561-
'file_target' => $qb->createNamedParameter($share->getTarget()),
572+
'file_target' => $qb->createNamedParameter($target),
562573
'permissions' => $qb->createNamedParameter($share->getPermissions()),
563574
'stime' => $qb->createNamedParameter($share->getShareTime()->getTimestamp()),
564575
])->execute();

lib/private/Share20/Manager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,12 @@ public function createShare(IShare $share) {
750750
}
751751

752752
// Generate the target
753-
$defaultShareFolder = $this->config->getSystemValue('share_folder', '/');
754-
$allowCustomShareFolder = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true);
755-
if ($allowCustomShareFolder) {
756-
$shareFolder = $this->config->getUserValue($share->getSharedWith(), Application::APP_ID, 'share_folder', $defaultShareFolder);
757-
} else {
758-
$shareFolder = $defaultShareFolder;
753+
$shareFolder = $this->config->getSystemValue('share_folder', '/');
754+
if ($share->getShareType() === IShare::TYPE_USER) {
755+
$allowCustomShareFolder = $this->config->getSystemValueBool('sharing.allow_custom_share_folder', true);
756+
if ($allowCustomShareFolder) {
757+
$shareFolder = $this->config->getUserValue($share->getSharedWith(), Application::APP_ID, 'share_folder', $shareFolder);
758+
}
759759
}
760760

761761
$target = $shareFolder . '/' . $share->getNode()->getName();

0 commit comments

Comments
 (0)