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

List hidden files if allowed #4328

Merged
merged 3 commits into from
Feb 25, 2019
Merged

List hidden files if allowed #4328

merged 3 commits into from
Feb 25, 2019

Conversation

maxmouchet
Copy link
Contributor

@maxmouchet maxmouchet commented Jan 8, 2019

This is an attempt to fix #3812 and jupyterlab/jupyterlab#2049.

If the listing of hidden files and directory is allowed, then we return them in the api/contents/: call so that they are displayed in the file manager of the notebook and lab interfaces.

I am not sure about the code style. Feel free to suggest a better way, if any.

@@ -334,7 +334,7 @@ def _dir_model(self, path, content=True):
self.log.debug("%s not a regular file", os_path)
continue

if self.should_list(name) and not is_file_hidden(os_path, stat_res=st):
if self.should_list(name) and ((not is_file_hidden(os_path, stat_res=st)) or self.allow_hidden):
contents.append(self.get(
path='%s/%s' % (path, name),
content=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic might be clearer split over a couple of lines:

if self.should_list(name):
    if self.allow_hidden or not is_file_hidden(os_path, stat_res=st):
        contents.append(
            self.get(path='%s/%s' % (path, name), content=False)
        )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed!

@dhirschfeld
Copy link
Contributor

ping @yuvipanda!

Since you asked on gitter I think all that is required is for someone to review and merge this PR.

@minrk minrk added this to the 5.8 milestone Feb 25, 2019
@minrk minrk merged commit 6d15e9c into jupyter:master Feb 25, 2019
@minrk
Copy link
Member

minrk commented Feb 25, 2019

Thanks!

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

Successfully merging this pull request may close these issues.

[Feature Request] List hidden files if ContentsManager.allow_hidden=True
3 participants