DIRAC icon indicating copy to clipboard operation
DIRAC copied to clipboard

findFilesByMetadata with invalid lfn

Open pigay opened this issue 9 years ago • 3 comments

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

pigay avatar Nov 20 '16 08:11 pigay

Again, I know nothing of these findFileByMetadata, they should rather be assigned to @atsareg. We don't have this working yet in our managers

chaen avatar Nov 22 '16 09:11 chaen

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?

pigay avatar Nov 23 '16 09:11 pigay

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

andresailer avatar Nov 21 '18 12:11 andresailer