fix(admin_audit): Do not log errors for new files

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/47071/head
Julius Härtl 2024-08-06 14:47:33 +07:00
parent 80fc2a96f2
commit 1c0f02eea9
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
1 changed files with 4 additions and 2 deletions

@ -7,6 +7,7 @@ declare(strict_types=1);
*/
namespace OCA\AdminAudit\Actions;
use OC\Files\Node\NonExistingFile;
use OCP\Files\Events\Node\BeforeNodeReadEvent;
use OCP\Files\Events\Node\BeforeNodeRenamedEvent;
use OCP\Files\Events\Node\BeforeNodeWrittenEvent;
@ -35,9 +36,10 @@ class Files extends Action {
*/
public function read(BeforeNodeReadEvent $event): void {
try {
$node = $event->getNode();
$params = [
'id' => $event->getNode()->getId(),
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
'id' => $node instanceof NonExistingFile ? null : $node->getId(),
'path' => mb_substr($node->getInternalPath(), 5),
];
} catch (InvalidPathException|NotFoundException $e) {
\OCP\Server::get(LoggerInterface::class)->error(