Skip to content

Commit

Permalink
fix(admin_audit): Fix incorrect truncation of files path in admin aud…
Browse files Browse the repository at this point in the history
…it log

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc authored and backportbot[bot] committed Feb 24, 2025
1 parent a1f7480 commit ee01d44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions apps/admin_audit/lib/Actions/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function read(BeforeNodeReadEvent $event): void {
$node = $event->getNode();
$params = [
'id' => $node instanceof NonExistingFile ? null : $node->getId(),
'path' => mb_substr($node->getInternalPath(), 5),
'path' => $node->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand Down Expand Up @@ -76,8 +76,8 @@ public function afterRename(NodeRenamedEvent $event): void {
$originalSource = $this->renamedNodes[$target->getId()];
$params = [
'newid' => $target->getId(),
'oldpath' => mb_substr($originalSource->getInternalPath(), 5),
'newpath' => mb_substr($target->getInternalPath(), 5),
'oldpath' => $originalSource->getPath(),
'newpath' => $target->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand All @@ -101,7 +101,7 @@ public function create(NodeCreatedEvent $event): void {
try {
$params = [
'id' => $event->getNode()->getId(),
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
'path' => $event->getNode()->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand All @@ -127,8 +127,8 @@ public function copy(NodeCopiedEvent $event): void {
$params = [
'oldid' => $event->getSource()->getId(),
'newid' => $event->getTarget()->getId(),
'oldpath' => mb_substr($event->getSource()->getInternalPath(), 5),
'newpath' => mb_substr($event->getTarget()->getInternalPath(), 5),
'oldpath' => $event->getSource()->getPath(),
'newpath' => $event->getTarget()->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand All @@ -151,7 +151,7 @@ public function write(NodeWrittenEvent $event): void {
try {
$params = [
'id' => $node->getId(),
'path' => mb_substr($node->getInternalPath(), 5),
'path' => $node->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand All @@ -177,7 +177,7 @@ public function delete(BeforeNodeDeletedEvent $event): void {
try {
$params = [
'id' => $event->getNode()->getId(),
'path' => mb_substr($event->getNode()->getInternalPath(), 5),
'path' => $event->getNode()->getPath(),
];
} catch (InvalidPathException|NotFoundException $e) {
Server::get(LoggerInterface::class)->error(
Expand Down
2 changes: 1 addition & 1 deletion apps/admin_audit/lib/Listener/FileEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private function beforePreviewFetched(BeforePreviewFetchedEvent $event): void {
'height' => $event->getHeight(),
'crop' => $event->isCrop(),
'mode' => $event->getMode(),
'path' => mb_substr($file->getInternalPath(), 5)
'path' => $file->getPath(),
];
$this->log(
'Preview accessed: (id: "%s", width: "%s", height: "%s" crop: "%s", mode: "%s", path: "%s")',
Expand Down

0 comments on commit ee01d44

Please sign in to comment.