fix: Avoid failing on fopen for NonExistingFiles

Signed-off-by: Julius Knorr <jus@bitgrid.net>
This commit is contained in:
Julius Knorr 2025-06-05 15:24:50 +02:00
parent 31c8db6639
commit 07dc03baaa
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -14,6 +14,7 @@ use OCA\Richdocuments\PermissionManager;
use OCP\Files\Folder;
use OCP\Files\ForbiddenException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\ISharedStorage;
use OCP\Files\Storage\IStorage;
use OCP\IUserSession;
@ -93,7 +94,12 @@ class SecureViewWrapper extends Wrapper {
$isSharedStorage = $storage->instanceOfStorage(ISharedStorage::class);
$mountNode = $this->rootFolder->get($storage->getMountPoint());
$node = $mountNode instanceof Folder ? $mountNode->get($path) : $mountNode;
try {
$node = $mountNode instanceof Folder ? $mountNode->get($path) : $mountNode;
} catch (NotFoundException $e) {
// If the file is just created we may need to check the parent as this is only just about figuring out if it is a share
$node = $mountNode->get(dirname($path));
}
$share = $isSharedStorage ? $node->getStorage()->getShare() : null;
$userId = $this->userSession->getUser()?->getUID();