Hello,
Iām developing a custom app for my Nextcloud instance that adds a new external storage backend option based on WebDAV, with some additional features. The integration works perfectly when connecting external storage using this new type. However, Iām encountering issues when trying to perform WebDAV operations like creating a folder. Specifically, the process fails under certain conditions.
Workflow Overview:
- When a user registers via the Registration app, a hook is triggered.
- This hook iterates through all external storages of the custom type.
- If the backend type is WebDAV, a request is sent to create a specific folder.
The Issue:
Sometimes, instead of the expected storage type \OC\Files\Storage\DAV
, the type is OCA\Files_Trashbin\Storage
. Below is the relevant code snippet:
foreach ($externalStorages as $externalStorage) {
if ($externalStorage->getBackend()->getIdentifier() != "customType") {
continue;
}
if (!$externalStorage->getBackendOption('auto_create_folder')) {
continue;
}
$mountPointInstance = $this->mountManager->find($externalStorage->getMountPoint());
$storageClass = $externalStorage->getBackend()->getStorageClass();
// Resolve the remote subfolder if it contains $user
$storageArguments = $externalStorage->getBackendOptions();
$resolvedMountpoint = str_replace('$user', $event->getUser()->getUID(), $externalStorage->getBackendOption('root'));
$storageArguments['root'] = $resolvedMountpoint;
// Get storage instance of type DAV to use mkdir and other functions
$storage = $this->storageFactory->getInstance($mountPointInstance, $storageClass, $storageArguments);
if ($storage instanceof DAV) {
// Create folder
}
}
When the type unexpectedly changes, disabling the āDeleted filesā app resolves the issue, and everything functions correctly. However, re-enabling the app causes the failure to return.
Question:
Why would enabling the āDeleted filesā app impact the storage type in this way? Is there something within my custom app or the Nextcloud environment that might be causing this interaction? Iām uncertain whether the problem lies within my app, but without the proper type check, the WebDAV operations will fail.
Any insights would be greatly appreciated!
Thank you.