Skip to content

Commit

Permalink
log warnings to give admins more infos about possibly miscalculated a…
Browse files Browse the repository at this point in the history
…ctivities.

Signed-off-by: Jan Messer <[email protected]>
  • Loading branch information
Messj1 committed Jul 22, 2024
1 parent 0b789c1 commit 04d7367
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,16 @@ protected function fileMoving($oldPath, $newPath) {
}
$accessList = $this->getUserPathsFromPath($parentPath, $parentOwner);
$affectedUsers = $accessList['users'];
$oldUsers = $this->oldAccessList['users'] ?? [];
$oldAccessList = $this->oldAccessList;
if($oldAccessList === null) {
$this->logger->warning("Something fishy happens: function fileMove was not finished: {oldPath} -> {path} : {uidOwner}",
['oldPath'=>$oldPath, 'path'=> $parentPath, 'uidOwner'=>$parentOwner]);
$oldAccessList = [
'users' => [],
'remotes' => [],
];
}
$oldUsers = $oldAccessList['users'];

// file can be shared using GroupFolders, including ACL check
if ($this->config->getSystemValueBool('activity_use_cached_mountpoints', false)) {
Expand All @@ -416,7 +425,7 @@ protected function fileMoving($oldPath, $newPath) {
$moveUsers = array_intersect($beforeUsers, $afterUsers);
$this->generateMoveActivities($moveUsers, $oldUsers, $affectedUsers, $fileId, $oldFileName, $parentId, $fileName);

$beforeRemotes = $this->oldAccessList['remotes'] ?? [];
$beforeRemotes = $oldAccessList['remotes'];
$afterRemotes = $accessList['remotes'];

$addRemotes = $deleteRemotes = $moveRemotes = [];
Expand Down Expand Up @@ -570,13 +579,17 @@ protected function getUserPathsFromPath($path, $uidOwner) {
try {
$node = $this->rootFolder->getUserFolder($uidOwner)->get($path);
} catch (NotFoundException $e) {
$this->logger->warning('Something fishy happens: Path "{path}" with owner "{uidOwner}" was not found',
['path'=> $path, 'uidOwner'=>$uidOwner]);
return [
'users' => [],
'remotes' => [],
];
}

if (!$node instanceof Node) {
$this->logger->warning('Something fishy happens: Path "{path}" of "{uidOwner}" is not a valid type.',
['path'=> $path, 'uidOwner'=>$uidOwner]);
return [
'users' => [],
'remotes' => [],
Expand Down

0 comments on commit 04d7367

Please sign in to comment.