Folder::searchByMime
does not work for folder under group folder #3537
Description
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Steps to reproduce
Prerequisite: Have a group folder configured and a sub-folder under it with some files. In the example below, I had a user named root
who had access to a group folder with hierarchy like this:
group_folder
|
--> subfolder
| |
| --> file2.md
| |
| --> file3.md
|
--> file1.md
Register the command class shown below to some app and run it with occ
for the folders group_folder
and group_folder/subfolder
:
The source code of the occ
command used above:
namespace OCA\Music\Command; // set to something suitable, I registered under the Music app as that was convenient for me
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SearchByMime extends Command {
private IRootFolder $rootFolder;
public function __construct(IRootFolder $rootFolder) {
parent::__construct();
$this->rootFolder = $rootFolder;
}
protected function configure() {
$this
->setName('search-by-mime')
->setDescription('Test the Folder::searchByMime function')
->addArgument(
'base_folder',
InputArgument::REQUIRED,
'path to the base folder of the search'
)
->addArgument(
'mime',
InputArgument::REQUIRED,
'mime (possibly partial) to search under base_folder'
)
;
}
protected function execute(InputInterface $input, OutputInterface $output) {
$path = $input->getArgument('base_folder');
try {
$folder = $this->rootFolder->get($path);
} catch (NotFoundException $e) {
// pass
}
if (!($folder instanceof Folder)) {
$output->writeln("<error>$path</error> is not a valid folder path");
return 1;
}
$mime = $input->getArgument('mime');
$found = $folder->searchByMime($mime);
$count = \count($found);
$output->writeln("Under folder <info>$path</info>, there are <info>$count</info> nodes matching mime <info>$mime</info>:");
foreach ($found as $node) {
$output->writeln($node->getPath());
}
return 0;
}
}
Expected behaviour
Folder::searchByMime
should find matching files also when used on a folder residing inside a group folder.
Actual behaviour
Folder::searchByMime
does not find any matching files when used on a folder residing inside a group folder. Using the function on the group folder itself finds those files.
This is the root cause of the bug owncloud/music#1195.
Server configuration
Operating system: Linux 6.1.19-v8+ aarch64
Web server: N/A
Database: SQLite 3.34.1
PHP version: 8.2.27
Nextcloud version: 30.0.2 RC1
Team folders version: 18.0.8
Updated from an older Nextcloud/ownCloud or fresh install: fresh
Where did you install Nextcloud from: https://download.nextcloud.com/server/
Are you using external storage, if yes which one: no
Are you using encryption: no
Are you using an external user-backend, if yes which one: no
Client configuration
N/A
Logs
N/A