Skip to content

Commit 270bd6c

Browse files
juliusknorrclaude
andcommitted
fix(sharing): indicate trashed files when listing orphan shares
A shared file moved to the trashbin keeps its file id, so it is flagged as an orphan share while still existing in the filecache. Detect this case and tell the admin the file is in the share owner's trashbin instead of the generic lost-access message. AI-assistant: Claude Code 2.1.156 (Claude Opus 4.8) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent 746f4ea commit 270bd6c

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎apps/files_sharing/lib/Command/DeleteOrphanShares.php‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function execute(InputInterface $input, OutputInterface $output): int {
5252
$exists = $this->orphanHelper->fileExists($share['fileid']);
5353
$output->writeln("<info>{$share['target']}</info> owned by <info>{$share['owner']}</info>");
5454
if ($exists) {
55-
$output->writeln(" file still exists but the share owner lost access to it, run <info>occ info:file {$share['fileid']}</info> for more information about the file");
55+
if ($this->orphanHelper->isInTrashbin($share['fileid'])) {
56+
$output->writeln(" file is in the trashbin of the share owner, run <info>occ info:file {$share['fileid']}</info> for more information about the file");
57+
} else {
58+
$output->writeln(" file still exists but the share owner lost access to it, run <info>occ info:file {$share['fileid']}</info> for more information about the file");
59+
}
5660
} else {
5761
$output->writeln(' file no longer exists');
5862
}

‎apps/files_sharing/lib/OrphanHelper.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ public function fileExists(int $fileId): bool {
5656
return $query->executeQuery()->fetchOne() !== false;
5757
}
5858

59+
public function isInTrashbin(int $fileId): bool {
60+
$query = $this->connection->getQueryBuilder();
61+
$query->select('path')
62+
->from('filecache')
63+
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
64+
$path = $query->executeQuery()->fetchOne();
65+
return $path !== false && str_starts_with($path, 'files_trashbin/');
66+
}
67+
5968
/**
6069
* @return \Traversable<int, array{id: int, owner: string, fileid: int, target: string}>
6170
*/

0 commit comments

Comments
 (0)