findFilesByMetadata with invalid lfn
Hi,
When providing an invalid (not existing directory, or even path of existing file), FileCatalog.findFilesBMetadata() will return results based on the first valid ancestor in the path string argument.
For instance, in filecatalog-cli:
$ dirac-dms-filecatalog-cli
Starting FileCatalog client
File Catalog Client $Revision: 1.17 $Date:
FC:/> cd /vo.france-grilles.fr/user/p/pgay/testdir
FC:/vo.france-grilles.fr/user/p/pgay/testdir>
FC:/vo.france-grilles.fr/user/p/pgay/testdir>
FC:/vo.france-grilles.fr/user/p/pgay/testdir>find .
Query: {}
/vo.france-grilles.fr/user/p/pgay/testdir/toto/titi/p1.sh
QueryTime 0.46 sec
FC:/vo.france-grilles.fr/user/p/pgay/testdir>
FC:/vo.france-grilles.fr/user/p/pgay/testdir>
FC:/vo.france-grilles.fr/user/p/pgay/testdir> find ./some/invalid/path
Query: {}
/vo.france-grilles.fr/user/p/pgay/testdir/toto/titi/p1.sh
QueryTime 0.46 sec
The two find commands return the same result while would expect the second to have an empty result.
Cheers,
Pierre
Again, I know nothing of these findFileByMetadata, they should rather be assigned to @atsareg. We don't have this working yet in our managers
I think I found how this happens.
If I understand well, the FileCatalog.findFileByMetadata() method calls DirectoryMetadata.findDirIDsByMetadata() wich in turn calls Directory<something>Tree.getPathIDs(). It's not clear for me which Directory<something>Tree is actually used, but getPathIDs seems to work similarly in each version.
It seems that in the end, Directory<something>Tree.getPathIDs() doesn't check if provided path is existing and queries the database in all possible ancestors to the faulty path. It turns out that if provided path is valid but doesn't exist, each existing ancestor will be returned (e.g. only / if no ancestor of path exists).
I'm not sure at which level this should be fixed. At least, the filecatalog-cli method could be added a check on existence of the provided path.
What do you think?
Upvote
Also similar, and maybe related...
dirac-dms-find-lfns Path=/ilc/user/s/someuser/folder/subfolder/subsubfolder
## finds the files in subsubfolder
dirac-dms-find-lfns Path=/ilc/user/s/someuser/folder/subfolder
## no files found, subfolder only contains subsubfolder