mirror of
https://github.com/nextcloud/server.git
synced 2026-05-26 11:22:28 -04:00
Merge pull request #25199 from owncloud/shared-mount-catch-9
[9.0] Catch exceptions while creating shared mounts
This commit is contained in:
commit
ddd4f367c3
2 changed files with 26 additions and 12 deletions
|
|
@ -111,7 +111,8 @@ class Application extends App {
|
|||
/** @var \OCP\IServerContainer $server */
|
||||
$server = $c->query('ServerContainer');
|
||||
return new MountProvider(
|
||||
$server->getConfig()
|
||||
$server->getConfig(),
|
||||
$server->getLogger()
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use OC\User\NoUserException;
|
|||
use OCP\Files\Config\IMountProvider;
|
||||
use OCP\Files\Storage\IStorageFactory;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use OCP\IUser;
|
||||
|
||||
class MountProvider implements IMountProvider {
|
||||
|
|
@ -36,10 +37,17 @@ class MountProvider implements IMountProvider {
|
|||
protected $config;
|
||||
|
||||
/**
|
||||
* @param \OCP\IConfig $config
|
||||
* @var ILogger
|
||||
*/
|
||||
public function __construct(IConfig $config) {
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @param \OCP\IConfig $config
|
||||
* @param ILogger $logger
|
||||
*/
|
||||
public function __construct(IConfig $config, ILogger $logger) {
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -57,15 +65,20 @@ class MountProvider implements IMountProvider {
|
|||
});
|
||||
$shares = array_map(function ($share) use ($user, $storageFactory) {
|
||||
|
||||
return new SharedMount(
|
||||
'\OC\Files\Storage\Shared',
|
||||
'/' . $user->getUID() . '/' . $share['file_target'],
|
||||
array(
|
||||
'share' => $share,
|
||||
'user' => $user->getUID()
|
||||
),
|
||||
$storageFactory
|
||||
);
|
||||
try {
|
||||
return new SharedMount(
|
||||
'\OC\Files\Storage\Shared',
|
||||
'/' . $user->getUID() . '/' . $share['file_target'],
|
||||
array(
|
||||
'share' => $share,
|
||||
'user' => $user->getUID()
|
||||
),
|
||||
$storageFactory
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e);
|
||||
$this->logger->error('Error while trying to create shared mount');
|
||||
}
|
||||
}, $shares);
|
||||
// array_filter removes the null values from the array
|
||||
return array_filter($shares);
|
||||
|
|
|
|||
Loading…
Reference in a new issue