Skip to content

Commit e7ced62

Browse files
committed
fix: do error on upload when a tag is not found anymore
- als removes a listener to CacheEntryInsertedEvent since CacheEntryUpdatedEvent will be called as well - logs a warning instead Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 2c861ca commit e7ced62

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/AppInfo/Application.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use OCP\AppFramework\Bootstrap\IBootContext;
1515
use OCP\AppFramework\Bootstrap\IBootstrap;
1616
use OCP\AppFramework\Bootstrap\IRegistrationContext;
17-
use OCP\Files\Cache\CacheEntryInsertedEvent;
1817
use OCP\Files\Cache\CacheEntryUpdatedEvent;
1918
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
2019

@@ -27,7 +26,6 @@ public function __construct() {
2726

2827
#[\Override]
2928
public function register(IRegistrationContext $context): void {
30-
$context->registerEventListener(CacheEntryInsertedEvent::class, CacheListener::class);
3129
$context->registerEventListener(CacheEntryUpdatedEvent::class, CacheListener::class);
3230

3331
$context->registerEventListener(RegisterOperationsEvent::class, RegisterFlowOperationsListener::class);

lib/Operation.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@
3131
use OCP\WorkflowEngine\IManager;
3232
use OCP\WorkflowEngine\IRuleMatcher;
3333
use OCP\WorkflowEngine\ISpecificOperation;
34+
use Psr\Log\LoggerInterface;
3435
use RuntimeException;
3536
use UnexpectedValueException;
3637

3738
class Operation implements ISpecificOperation, IComplexOperation {
39+
protected array $issuedTagNotFoundWarnings = [];
40+
3841
public function __construct(
3942
protected readonly ISystemTagObjectMapper $objectMapper,
4043
protected readonly ISystemTagManager $tagManager,
@@ -47,6 +50,7 @@ public function __construct(
4750
protected readonly File $fileEntity,
4851
protected readonly IUserSession $userSession,
4952
protected readonly IGroupManager $groupManager,
53+
protected readonly LoggerInterface $logger,
5054
) {
5155
}
5256

@@ -64,7 +68,19 @@ public function checkOperations(IStorage $storage, int $fileId, string $file): v
6468
$matches = $matcher->getFlows(false);
6569

6670
foreach ($matches as $match) {
67-
$this->objectMapper->assignTags((string)$fileId, 'files', explode(',', $match['operation']));
71+
try {
72+
$this->objectMapper->assignTags((string)$fileId, 'files', explode(',', $match['operation']));
73+
} catch (TagNotFoundException $e) {
74+
$msg = sprintf('The tag to assign (ID %s) cannot be found anymore. The related rule is %s.',
75+
$match['operation'],
76+
$match['scope_type'] === 0 ? 'global' : 'owned by ' . $match['scope_actor_id']
77+
);
78+
if (isset($this->issuedTagNotFoundWarnings[md5($msg)])) {
79+
continue;
80+
}
81+
$this->issuedTagNotFoundWarnings[md5($msg)] = true;
82+
$this->logger->error($msg);
83+
}
6884
}
6985
}
7086

0 commit comments

Comments
 (0)