diff options
author | Robin Appelman <robin@icewind.nl> | 2021-05-10 17:34:10 +0200 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2021-05-19 17:08:20 +0200 |
commit | ed2396b045c7b10555d7f05df5f81d2d17a00caf (patch) | |
tree | a467de2d39cb89fb76b061246b92c7cf56940a82 /apps/files_external/lib | |
parent | fd284f428dc15c0ebd4054fa5e4e9431d518bcb1 (diff) | |
download | nextcloud-server-ed2396b045c7b10555d7f05df5f81d2d17a00caf.tar.gz nextcloud-server-ed2396b045c7b10555d7f05df5f81d2d17a00caf.zip |
better cleanup of filecache when deleting an external storage
this way it can delete the cache entries even with per-user credentials
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps/files_external/lib')
-rw-r--r-- | apps/files_external/lib/Service/StoragesService.php | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/apps/files_external/lib/Service/StoragesService.php b/apps/files_external/lib/Service/StoragesService.php index 63f0c5d52c5..334b1c5041a 100644 --- a/apps/files_external/lib/Service/StoragesService.php +++ b/apps/files_external/lib/Service/StoragesService.php @@ -479,44 +479,7 @@ abstract class StoragesService { $this->triggerHooks($deletedStorage, Filesystem::signal_delete_mount); // delete oc_storages entries and oc_filecache - try { - $rustyStorageId = $this->getRustyStorageIdFromConfig($deletedStorage); - \OC\Files\Cache\Storage::remove($rustyStorageId); - } catch (\Exception $e) { - // can happen either for invalid configs where the storage could not - // be instantiated or whenever $user vars where used, in which case - // the storage id could not be computed - \OC::$server->getLogger()->logException($e, [ - 'level' => ILogger::ERROR, - 'app' => 'files_external', - ]); - } - } - - /** - * Returns the rusty storage id from oc_storages from the given storage config. - * - * @param StorageConfig $storageConfig - * @return string rusty storage id - */ - private function getRustyStorageIdFromConfig(StorageConfig $storageConfig) { - // if any of the storage options contains $user, it is not possible - // to compute the possible storage id as we don't know which users - // mounted it already (and we certainly don't want to iterate over ALL users) - foreach ($storageConfig->getBackendOptions() as $value) { - if (strpos($value, '$user') !== false) { - throw new \Exception('Cannot compute storage id for deletion due to $user vars in the configuration'); - } - } - - // note: similar to ConfigAdapter->prepateStorageConfig() - $storageConfig->getAuthMechanism()->manipulateStorageConfig($storageConfig); - $storageConfig->getBackend()->manipulateStorageConfig($storageConfig); - - $class = $storageConfig->getBackend()->getStorageClass(); - $storageImpl = new $class($storageConfig->getBackendOptions()); - - return $storageImpl->getId(); + \OC\Files\Cache\Storage::cleanByMountId($id); } /** |