Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Depth search for Files/Directories #430

Open
ghost opened this issue Feb 12, 2019 · 4 comments
Open

Question: Depth search for Files/Directories #430

ghost opened this issue Feb 12, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Feb 12, 2019

Hey, is there any way of realising a depth search for specific files ?

I tried manually to implement a depth search with recursion and Directory#list(). But this is really really slow on a share with many directories, cause I have to share#open() every new recursion step individually, which takes up some time.

Or can I change any of the required parameters for share#open() to be "faster" e.g. only retrieve It's meta data, or enough to call Directory#list() on it ?
I tried reading through the Specification, and found out that there is no actual SMB method for it, but I may be wrong, or missing something.

Hope someone can help me on this.

@pepijnve
Copy link
Contributor

If I understand you correctly you're trying to do something like find . -name <some name>. If that's the case, no there's no way to accelerate that besides doing a full recursive directory listing. Best you can do is parallelise the process rather than doing the scan single threaded. There's no way to parallelise listing of a single directory, but you can list multiple directories in parallel.

@pepijnve
Copy link
Contributor

BTW, be sure to use Directory#iterator instead of Directory#list for this. Directory listing over SMB is done in chunks. list will block until the entire directory has been listed and will hold all entries for the directory in memory. iterator only holds on to one chunk and will fetch the next chunk when needed. This allows you to stream the results which will be much less resource intensive than list.

@ghost
Copy link
Author

ghost commented Feb 12, 2019 via email

@rokkakasu
Copy link

rokkakasu commented Mar 19, 2023

Hi @hierynomus I have created the implementation for Listing all files recursively with single session.
Present implementation lists files under single directory and creates NTLM authentication for each sub-folders to list files.
Kindly check my PR and approve.
#754

Thanks
@rokkakasu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants