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

Skip branches #3

Open
mottosso opened this issue Jul 2, 2014 · 4 comments
Open

Skip branches #3

mottosso opened this issue Jul 2, 2014 · 4 comments

Comments

@mottosso
Copy link
Member

mottosso commented Jul 2, 2014

Special-purpose metadata to indicate that a folder and its content should be skipped.

$ /home/marcus/private_stuff/.meta/skip.class

Upon querying the descending hierarchy or marcus, do not proceed into nor further than private_stuff. Surrounding branches are still queried. The idea is to limit the breadth of cQuery for branches of the file-system that should not be traversed; such as administrative folders or temporary storages.

@ghost
Copy link

ghost commented Jul 2, 2014

That looks like a neat way of defining folder structures that should be ignored by cQuery.

I think that it might be a good idea to make sure that the --verbose flag of cQuery prints some debug information when it reaches one of those folders so the user is aware that anything that exists within those folders will be ignored by the tool even if it contains metadata. Otherwise, it might be a bit difficult to debug why some folders are not picked up when performing a search.

@mottosso
Copy link
Member Author

mottosso commented Jul 2, 2014

Good point. How about something like this:

/projects/spiderman/assets/Peter
/projects/spiderman/assets/Mary
                     Selector .Asset
                     2 results in 0.003s
                     Skipped
                         /projects/spiderman/secret_stuff
                         /projects/spiderman/more_stuff
                         /projects/spiderman/internal_data

Also, would ignore make for a better name than skip?

@mottosso mottosso changed the title --skip Skip branches Jul 2, 2014
@ghost
Copy link

ghost commented Jul 2, 2014

Yeah, that looks great! I assume that this is what you would get when using the command line. How would you go about implementing it when using cQuery from a Python script and not interfere with any values returned?

In regards of the name, I would personally go for ignore.

@mottosso
Copy link
Member Author

mottosso commented Jul 2, 2014

Tough question, let's brainstorm:

1. Alter return value

This is how languages like Go does it, always return more than required, and leave it up to the user to ignore what they don't need. Works, but leaves quite a mess.

>>> match, stats = cquery.first_match("/home/marcus", ".Asset")
>>> stats
{'ignored: ["/home/marcus/private", "/home/marcus/another_private"]}

To ignore stats:

>>> match, _ = cquery.first_match("/home/marcus", ".Asset")
>>> match
/home/marcus/assets/Peter

2. External query

It would most likely be a debugging feature, so it may make sense to put into an additional method, although it would incur additional cost in terms of processing and traversing as we would have to run a scan twice if we needed to get both queries and ignored directories.

>>> ignored = cquery.ignored("/home/marcus")
>>> ignored
["/home/marcus/private", "/home/marcus/another_private"]

At this point, the return value could get cached and stored within the index for faster retrieval.

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

No branches or pull requests

1 participant