Merge pull request #47071 from nextcloud/fix/no-error-new-file-audit

fix(admin_audit): Do not log errors for new files
This commit is contained in:
Andy Scherzinger 2024-08-07 11:42:38 +02:00 committed by GitHub
commit 0050e1e219
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(