summaryrefslogtreecommitdiffstats
path: root/apps/files_external/service
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/service')
-rw-r--r--apps/files_external/service/storagesservice.php40
-rw-r--r--apps/files_external/service/userglobalstoragesservice.php7
-rw-r--r--apps/files_external/service/userstoragesservice.php7
3 files changed, 49 insertions, 5 deletions
diff --git a/apps/files_external/service/storagesservice.php b/apps/files_external/service/storagesservice.php
index c0dd263ed66..678b91c0109 100644
--- a/apps/files_external/service/storagesservice.php
+++ b/apps/files_external/service/storagesservice.php
@@ -31,6 +31,7 @@ use \OCA\Files_external\Lib\StorageConfig;
use \OCA\Files_external\NotFoundException;
use \OCA\Files_External\Lib\Backend\Backend;
use \OCA\Files_External\Lib\Auth\AuthMechanism;
+use OCP\Files\Config\IUserMountCache;
use \OCP\Files\StorageNotAvailableException;
/**
@@ -47,12 +48,19 @@ abstract class StoragesService {
protected $dbConfig;
/**
+ * @var IUserMountCache
+ */
+ protected $userMountCache;
+
+ /**
* @param BackendService $backendService
* @param DBConfigService $dbConfigService
+ * @param IUserMountCache $userMountCache
*/
- public function __construct(BackendService $backendService, DBConfigService $dbConfigService) {
+ public function __construct(BackendService $backendService, DBConfigService $dbConfigService, IUserMountCache $userMountCache) {
$this->backendService = $backendService;
$this->dbConfig = $dbConfigService;
+ $this->userMountCache = $userMountCache;
}
protected function readDBConfig() {
@@ -416,6 +424,15 @@ abstract class StoragesService {
$this->triggerChangeHooks($oldStorage, $updatedStorage);
+ if (($wasGlobal && !$isGlobal) || count($removedGroups) > 0) { // to expensive to properly handle these on the fly
+ $this->userMountCache->remoteStorageMounts($this->getStorageId($updatedStorage));
+ } else {
+ $storageId = $this->getStorageId($updatedStorage);
+ foreach ($removedUsers as $userId) {
+ $this->userMountCache->removeUserStorageMount($storageId, $userId);
+ }
+ }
+
return $this->getStorage($id);
}
@@ -480,4 +497,25 @@ abstract class StoragesService {
return $storageImpl->getId();
}
+ /**
+ * Construct the storage implementation
+ *
+ * @param StorageConfig $storageConfig
+ * @return int
+ */
+ private function getStorageId(StorageConfig $storageConfig) {
+ try {
+ $class = $storageConfig->getBackend()->getStorageClass();
+ /** @var \OC\Files\Storage\Storage $storage */
+ $storage = new $class($storageConfig->getBackendOptions());
+
+ // auth mechanism should fire first
+ $storage = $storageConfig->getBackend()->wrapStorage($storage);
+ $storage = $storageConfig->getAuthMechanism()->wrapStorage($storage);
+
+ return $storage->getStorageCache()->getNumericId();
+ } catch (\Exception $e) {
+ return -1;
+ }
+ }
}
diff --git a/apps/files_external/service/userglobalstoragesservice.php b/apps/files_external/service/userglobalstoragesservice.php
index 6407db2dd54..03c831fe971 100644
--- a/apps/files_external/service/userglobalstoragesservice.php
+++ b/apps/files_external/service/userglobalstoragesservice.php
@@ -25,6 +25,7 @@ namespace OCA\Files_External\Service;
use \OCA\Files_external\Service\GlobalStoragesService;
use \OCA\Files_External\Service\BackendService;
+use OCP\Files\Config\IUserMountCache;
use \OCP\IUserSession;
use \OCP\IGroupManager;
use \OCA\Files_External\Service\UserTrait;
@@ -46,14 +47,16 @@ class UserGlobalStoragesService extends GlobalStoragesService {
* @param DBConfigService $dbConfig
* @param IUserSession $userSession
* @param IGroupManager $groupManager
+ * @param IUserMountCache $userMountCache
*/
public function __construct(
BackendService $backendService,
DBConfigService $dbConfig,
IUserSession $userSession,
- IGroupManager $groupManager
+ IGroupManager $groupManager,
+ IUserMountCache $userMountCache
) {
- parent::__construct($backendService, $dbConfig);
+ parent::__construct($backendService, $dbConfig, $userMountCache);
$this->userSession = $userSession;
$this->groupManager = $groupManager;
}
diff --git a/apps/files_external/service/userstoragesservice.php b/apps/files_external/service/userstoragesservice.php
index 2805d9e6935..d4b04de609d 100644
--- a/apps/files_external/service/userstoragesservice.php
+++ b/apps/files_external/service/userstoragesservice.php
@@ -23,6 +23,7 @@
namespace OCA\Files_external\Service;
+use OCP\Files\Config\IUserMountCache;
use \OCP\IUserSession;
use \OC\Files\Filesystem;
@@ -44,14 +45,16 @@ class UserStoragesService extends StoragesService {
* @param BackendService $backendService
* @param DBConfigService $dbConfig
* @param IUserSession $userSession user session
+ * @param IUserMountCache $userMountCache
*/
public function __construct(
BackendService $backendService,
DBConfigService $dbConfig,
- IUserSession $userSession
+ IUserSession $userSession,
+ IUserMountCache $userMountCache
) {
$this->userSession = $userSession;
- parent::__construct($backendService, $dbConfig);
+ parent::__construct($backendService, $dbConfig, $userMountCache);
}
protected function readDBConfig() {