Skip to content

Commit 5b04480

Browse files
authored
Merge pull request #213 from nextcloud/fix/on-insert
perf(FsEventService): Avoid fetching nodes
2 parents 6f1e0a9 + f83ad05 commit 5b04480

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

lib/Service/FsEventService.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use OCA\ContextChat\Db\QueueFile;
1212
use OCA\ContextChat\Logger;
1313
use OCP\DB\Exception;
14-
use OCP\Files\File;
1514
use OCP\Files\Folder;
1615
use OCP\Files\InvalidPathException;
1716
use OCP\Files\IRootFolder;
@@ -117,27 +116,13 @@ public function onInsert(Node $node, bool $recurse = true, bool $update = false)
117116
}
118117

119118
foreach ($fileIds as $fileId) {
120-
$file = $this->rootFolder->getFirstNodeById($fileId);
121-
if (!$file instanceof File) {
122-
continue;
123-
}
124-
if (!$this->allowedPath($file)) {
125-
continue;
126-
}
127119
$queueFile = new QueueFile();
128-
if ($file->getMountPoint()->getNumericStorageId() === null) {
120+
if ($node->getMountPoint()->getNumericStorageId() === null) {
129121
return;
130122
}
131-
$queueFile->setStorageId($file->getMountPoint()->getNumericStorageId());
132-
$queueFile->setRootId($file->getMountPoint()->getStorageRootId());
133-
134-
try {
135-
$queueFile->setFileId($file->getId());
136-
} catch (InvalidPathException|NotFoundException $e) {
137-
$this->logger->warning($e->getMessage(), ['exception' => $e]);
138-
return;
139-
}
140-
123+
$queueFile->setStorageId($node->getMountPoint()->getNumericStorageId());
124+
$queueFile->setRootId($node->getMountPoint()->getStorageRootId());
125+
$queueFile->setFileId($fileId);
141126
$queueFile->setUpdate($update);
142127
try {
143128
$this->queue->insertIntoQueue($queueFile);

0 commit comments

Comments
 (0)