*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Jonas Meurer <jonas@freesources.org>
*
* @license GNU AGPL version 3 or any later version
*
namespace OCA\WorkflowEngine\Entity;
use OC\Files\Config\UserMountCache;
+use OC\Files\Mount\Manager as MountManager;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\GenericEvent;
use OCP\Files\InvalidPathException;
private $userManager;
/** @var UserMountCache */
private $userMountCache;
+ /** @var MountManager */
+ private $mountManager;
public function __construct(
IL10N $l10n,
IUserSession $userSession,
ISystemTagManager $tagManager,
IUserManager $userManager,
- UserMountCache $userMountCache
+ UserMountCache $userMountCache,
+ MountManager $mountManager
) {
$this->l10n = $l10n;
$this->urlGenerator = $urlGenerator;
$this->tagManager = $tagManager;
$this->userManager = $userManager;
$this->userMountCache = $userMountCache;
+ $this->mountManager = $mountManager;
}
public function getName(): string {
$fileId = $node->getId();
}
- $mounts = $this->userMountCache->getMountsForFileId($fileId, $uid);
- foreach ($mounts as $mount) {
- $userFolder = $this->root->getUserFolder($uid);
- if (!empty($userFolder->getById($fileId))) {
+ $mountInfos = $this->userMountCache->getMountsForFileId($fileId, $uid);
+ foreach ($mountInfos as $mountInfo) {
+ $mount = $this->mountManager->getMountFromMountInfo($mountInfo);
+ if ($mount && $mount->getStorage() && !empty($mount->getStorage()->getCache()->get($fileId))) {
return true;
}
}
namespace OCA\WorkflowEngine\Tests;
use OC\Files\Config\UserMountCache;
+use OC\Files\Mount\Manager as MountManager;
use OC\L10N\L10N;
use OCA\WorkflowEngine\Entity\File;
use OCA\WorkflowEngine\Helper\ScopeContext;
$this->createMock(ISystemTagManager::class),
$this->createMock(IUserManager::class),
$this->createMock(UserMountCache::class),
+ $this->createMock(MountManager::class),
])
->setMethodsExcept(['getEvents'])
->getMock();
* @author Robin Appelman <robin@icewind.nl>
* @author Robin McCorkell <robin@mccorkell.me.uk>
* @author Roeland Jago Douma <roeland@famdouma.nl>
+ * @author Jonas <jonas@freesources.org>
*
* @license AGPL-3.0
*
use OC\Files\Filesystem;
use OC\Files\SetupManager;
use OC\Files\SetupManagerFactory;
+use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
});
}
}
+
+ /**
+ * Return the mount matching a cached mount info (or mount file info)
+ *
+ * @param ICachedMountInfo $info
+ *
+ * @return IMountPoint|null
+ */
+ public function getMountFromMountInfo(ICachedMountInfo $info): ?IMountPoint {
+ $this->setupManager->setupForPath($info->getMountPoint());
+ foreach ($this->mounts as $mount) {
+ if ($mount->getMountPoint() === $info->getMountPoint()) {
+ return $mount;
+ }
+ }
+ return null;
+ }
}