summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--apps/files_external/appinfo/app.php2
-rw-r--r--apps/files_external/lib/AppInfo/Application.php28
-rw-r--r--apps/files_external/lib/Service/DBConfigService.php32
-rw-r--r--core/img/actions/history.pngbin358 -> 291 bytes
-rw-r--r--core/img/actions/history.svg2
-rw-r--r--lib/private/Files/Storage/Common.php4
7 files changed, 67 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index d0d8fe14122..4e6967c19d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -135,6 +135,7 @@ Vagrantfile
# Tests - auto-generated files
/data-autotest
+/tests/.phpunit.result.cache
/tests/coverage*
/tests/css
/tests/karma-coverage
diff --git a/apps/files_external/appinfo/app.php b/apps/files_external/appinfo/app.php
index 856b04fde15..7d0301dd588 100644
--- a/apps/files_external/appinfo/app.php
+++ b/apps/files_external/appinfo/app.php
@@ -34,6 +34,8 @@ require_once __DIR__ . '/../3rdparty/autoload.php';
// register Application object singleton
\OC_Mount_Config::$app = \OC::$server->query(\OCA\Files_External\AppInfo\Application::class);
+\OC_Mount_Config::$app->registerListeners();
+
$appContainer = \OC_Mount_Config::$app->getContainer();
\OCA\Files\App::getNavigationManager()->add(function () {
diff --git a/apps/files_external/lib/AppInfo/Application.php b/apps/files_external/lib/AppInfo/Application.php
index 1ee7cb08ccf..47c88a67d20 100644
--- a/apps/files_external/lib/AppInfo/Application.php
+++ b/apps/files_external/lib/AppInfo/Application.php
@@ -30,6 +30,7 @@
namespace OCA\Files_External\AppInfo;
use OCA\Files_External\Config\UserPlaceholderHandler;
+use OCA\Files_External\Service\DBConfigService;
use OCA\Files_External\Lib\Auth\AmazonS3\AccessKey;
use OCA\Files_External\Lib\Auth\Builtin;
use OCA\Files_External\Lib\Auth\NullMechanism;
@@ -63,6 +64,9 @@ use OCA\Files_External\Service\BackendService;
use OCP\AppFramework\App;
use OCP\AppFramework\IAppContainer;
use OCP\Files\Config\IUserMountCache;
+use OCP\IGroup;
+use OCP\IUser;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* @package OCA\Files_External\AppInfo
@@ -96,6 +100,30 @@ class Application extends App implements IBackendProvider, IAuthMechanismProvide
$this->getAuthMechanisms();
}
+ public function registerListeners() {
+ $dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
+ $dispatcher->addListener(
+ IUser::class . '::postDelete',
+ function (GenericEvent $event) {
+ /** @var IUser $user */
+ $user = $event->getSubject();
+ /** @var DBConfigService $config */
+ $config = $this->getContainer()->query(DBConfigService::class);
+ $config->modifyMountsOnUserDelete($user->getUID());
+ }
+ );
+ $dispatcher->addListener(
+ IGroup::class . '::postDelete',
+ function (GenericEvent $event) {
+ /** @var IGroup $group */
+ $group = $event->getSubject();
+ /** @var DBConfigService $config */
+ $config = $this->getContainer()->query(DBConfigService::class);
+ $config->modifyMountsOnGroupDelete($group->getGID());
+ }
+ );
+ }
+
/**
* @{inheritdoc}
*/
diff --git a/apps/files_external/lib/Service/DBConfigService.php b/apps/files_external/lib/Service/DBConfigService.php
index 65995b21cc4..9394924d396 100644
--- a/apps/files_external/lib/Service/DBConfigService.php
+++ b/apps/files_external/lib/Service/DBConfigService.php
@@ -114,6 +114,38 @@ class DBConfigService {
return $this->getMountsFromQuery($query);
}
+ public function modifyMountsOnUserDelete(string $uid): void {
+ $this->modifyMountsOnDelete($uid, self::APPLICABLE_TYPE_USER);
+ }
+
+ public function modifyMountsOnGroupDelete(string $gid): void {
+ $this->modifyMountsOnDelete($gid, self::APPLICABLE_TYPE_GROUP);
+ }
+
+ protected function modifyMountsOnDelete(string $applicableId, int $applicableType): void {
+ $builder = $this->connection->getQueryBuilder();
+ $query = $builder->select(['a.mount_id', $builder->func()->count('a.mount_id', 'count')])
+ ->from('external_applicable', 'a')
+ ->rightJoin('a', 'external_applicable', 'b', $builder->expr()->eq('a.mount_id', 'b.mount_id'))
+ ->where($builder->expr()->andX(
+ $builder->expr()->eq('a.type', $builder->createNamedParameter($applicableType, IQueryBuilder::PARAM_INT)),
+ $builder->expr()->eq('a.value', $builder->createNamedParameter($applicableId))
+ )
+ )
+ ->groupBy(['a.mount_id']);
+ $stmt = $query->execute();
+ $result = $stmt->fetchAll();
+ $stmt->closeCursor();
+
+ foreach ($result as $row) {
+ if((int)$row['count'] > 1) {
+ $this->removeApplicable($row['mount_id'], $applicableType, $applicableId);
+ } else {
+ $this->removeMount($row['mount_id']);
+ }
+ }
+ }
+
/**
* Get admin defined mounts
*
diff --git a/core/img/actions/history.png b/core/img/actions/history.png
index 11eb83309fb..e3289b19830 100644
--- a/core/img/actions/history.png
+++ b/core/img/actions/history.png
Binary files differ
diff --git a/core/img/actions/history.svg b/core/img/actions/history.svg
index bb09c568260..e98c63ddda7 100644
--- a/core/img/actions/history.svg
+++ b/core/img/actions/history.svg
@@ -1 +1 @@
-<svg width="16" height="16" version="1.1" viewbox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="m7.9319 2.4252c-3.4324 0-5.6787 2.9953-5.5301 5.8394h-1.8778l3.3924 3.4063 3.5454-3.3664h-1.8657c-0.20594-1.4772 1.0106-2.706 2.3366-2.6868 1.386 0.020855 2.4331 1.0688 2.4331 2.3758 0.07821 1.3851-1.4164 2.9788-3.4463 2.1985 0 1.0688 0.00261 2.2115 0 3.2717 3.641 0.72124 6.6389-2.1811 6.6389-5.431 0-3.0961-2.5374-5.6074-5.6266-5.6074z"/></svg>
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/></svg>
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index 3bc14d35cd0..d1913c28d7e 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -535,7 +535,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
}
}
- if (isset($fileName[255])) {
+ // 255 characters is the limit on common file systems (ext/xfs)
+ // oc_filecache has a 250 char length limit for the filename
+ if (isset($fileName[250])) {
throw new FileNameTooLongException();
}