-
Notifications
You must be signed in to change notification settings - Fork 18
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
Exclude hidden files from recent recommendations #354
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Brett Kleinschmidt <blk@blk.me>
7225783
to
80d1349
Compare
try { | ||
$next = $next->getParent(); | ||
} catch (NotFoundException $e) { | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't you run into an infinite loop here?
I think you would be better off with recursion. If the current node is hidden, you return false
. If there is a parent you return $this->isNodeExcluded($node->getParent(), $showHidden);
. Else you return false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking a look!
The sequence ends when a dotfile is found (return true
) or the root node is found (break
). In other words, it is always bounded by the depth of the node. If there were a clearer way to identify the root node other than by exception handling then I would be more than happy to use it.
While I agree that recursion is generally a more natural approach to tree traversal problems, I don't think anything is lost in this context by iterating. And in the recursive case, we would want to introduce a new function so that isNodeExcluded
can be adapted to other types of exclusions related to the target node (name, mimetype, tag, etc.).
Please rebase? 🙈 |
Resolves #71 by
getMostRecentRecommendation
to better allow for filtering of results.isNodeExcluded
in order to exclude nodes which are either hidden files or descendants of hidden folders. A traversal of the file system hierarchy is necessary to find hidden ancestors, which greatly reduces the worst-case time complexity.The number of candidate files is arbitrarily limited by 10 times the actual number requested.