Skip to content

Commit 841f2f3

Browse files
committed
Allow to overwrite share target mountpoints
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent 6895a23 commit 841f2f3

4 files changed

Lines changed: 93 additions & 0 deletions

File tree

apps/files_sharing/lib/SharedMount.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
use OC\Files\Mount\MountPoint;
3434
use OC\Files\Mount\MoveableMount;
3535
use OC\Files\View;
36+
use OCP\EventDispatcher\IEventDispatcher;
3637
use OCP\Files\Storage\IStorageFactory;
38+
use OCP\Share\Events\VerifyMountPointEvent;
3739

3840
/**
3941
* Shared mount points can be moved by the user
@@ -91,6 +93,12 @@ private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints,
9193
$mountPoint = basename($share->getTarget());
9294
$parent = dirname($share->getTarget());
9395

96+
$event = new VerifyMountPointEvent($share, $this->recipientView, $parent);
97+
/** @var IEventDispatcher $dispatcher */
98+
$dispatcher = \OC::$server->query(IEventDispatcher::class);
99+
$dispatcher->dispatchTyped($event);
100+
$parent = $event->getParent();
101+
94102
if ($folderExistCache->hasKey($parent)) {
95103
$parentExists = $folderExistCache->get($parent);
96104
} else {

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@
428428
'OCP\\Settings\\ISubAdminSettings' => $baseDir . '/lib/public/Settings/ISubAdminSettings.php',
429429
'OCP\\Share' => $baseDir . '/lib/public/Share.php',
430430
'OCP\\Share\\Events\\ShareCreatedEvent' => $baseDir . '/lib/public/Share/Events/ShareCreatedEvent.php',
431+
'OCP\\Share\\Events\\VerifyMountPointEvent' => $baseDir . '/lib/public/Share/Events/VerifyMountPointEvent.php',
431432
'OCP\\Share\\Exceptions\\GenericShareException' => $baseDir . '/lib/public/Share/Exceptions/GenericShareException.php',
432433
'OCP\\Share\\Exceptions\\IllegalIDChangeException' => $baseDir . '/lib/public/Share/Exceptions/IllegalIDChangeException.php',
433434
'OCP\\Share\\Exceptions\\ShareNotFound' => $baseDir . '/lib/public/Share/Exceptions/ShareNotFound.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
457457
'OCP\\Settings\\ISubAdminSettings' => __DIR__ . '/../../..' . '/lib/public/Settings/ISubAdminSettings.php',
458458
'OCP\\Share' => __DIR__ . '/../../..' . '/lib/public/Share.php',
459459
'OCP\\Share\\Events\\ShareCreatedEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/ShareCreatedEvent.php',
460+
'OCP\\Share\\Events\\VerifyMountPointEvent' => __DIR__ . '/../../..' . '/lib/public/Share/Events/VerifyMountPointEvent.php',
460461
'OCP\\Share\\Exceptions\\GenericShareException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/GenericShareException.php',
461462
'OCP\\Share\\Exceptions\\IllegalIDChangeException' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/IllegalIDChangeException.php',
462463
'OCP\\Share\\Exceptions\\ShareNotFound' => __DIR__ . '/../../..' . '/lib/public/Share/Exceptions/ShareNotFound.php',
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?php
2+
declare(strict_types=1);
3+
/**
4+
* @copyright Copyright (c) 2020, Joas Schilling <coding@schilljs.com>
5+
*
6+
* @author Joas Schilling <coding@schilljs.com>
7+
*
8+
* @license GNU AGPL version 3 or any later version
9+
*
10+
* This program is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Affero General Public License as
12+
* published by the Free Software Foundation, either version 3 of the
13+
* License, or (at your option) any later version.
14+
*
15+
* This program is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Affero General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Affero General Public License
21+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
namespace OCP\Share\Events;
26+
27+
use OC\Files\View;
28+
use OCP\EventDispatcher\Event;
29+
use OCP\Share\IShare;
30+
31+
/**
32+
* @since 19.0.0
33+
*/
34+
class VerifyMountPointEvent extends Event {
35+
36+
/** @var IShare */
37+
private $share;
38+
/** @var View */
39+
private $view;
40+
/** @var string */
41+
private $parent;
42+
43+
/**
44+
* @since 19.0.0
45+
*/
46+
public function __construct(IShare $share,
47+
View $view,
48+
string $parent) {
49+
parent::__construct();
50+
51+
$this->share = $share;
52+
$this->view = $view;
53+
$this->parent = $parent;
54+
}
55+
56+
/**
57+
* @since 19.0.0
58+
*/
59+
public function getShare(): IShare {
60+
return $this->share;
61+
}
62+
63+
/**
64+
* @since 19.0.0
65+
*/
66+
public function getView(): View {
67+
return $this->view;
68+
}
69+
70+
/**
71+
* @since 19.0.0
72+
*/
73+
public function getParent(): string {
74+
return $this->parent;
75+
}
76+
77+
/**
78+
* @since 19.0.0
79+
*/
80+
public function setParent(string $parent): void {
81+
$this->parent = $parent;
82+
}
83+
}

0 commit comments

Comments
 (0)