Skip to content

Commit

Permalink
Merge pull request #1957 from nextcloud/enh/perf-read
Browse files Browse the repository at this point in the history
Emit read hook instead of fopen for admin_audit
  • Loading branch information
juliusknorr authored May 18, 2022
2 parents 3eae49a + 3f8f5c5 commit 2ea6b6a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace OCA\Richdocuments;

use InvalidArgumentException;
use OC\Files\Filesystem;
use OCA\Richdocuments\Db\Direct;
use OCA\Richdocuments\Db\WopiMapper;
use OCA\Richdocuments\Db\Wopi;
Expand Down Expand Up @@ -191,8 +192,11 @@ public function getToken($fileId, $shareToken = null, $editoruid = null, $direct
}

// force read operation to trigger possible audit logging
$fp = $file->fopen('r');
fclose($fp);
\OC_Hook::emit(
Filesystem::CLASSNAME,
Filesystem::signal_read,
[Filesystem::signal_param_path => $file->getPath()]
);

$serverHost = $this->urlGenerator->getAbsoluteURL('/');
$guestName = $this->userId === null ? $this->prepareGuestName($this->helper->getGuestNameFromCookie()) : null;
Expand Down

0 comments on commit 2ea6b6a

Please sign in to comment.