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

Readdir returns sub-subfolders #58

Closed
dkumor opened this issue Feb 16, 2019 · 2 comments
Closed

Readdir returns sub-subfolders #58

dkumor opened this issue Feb 16, 2019 · 2 comments

Comments

@dkumor
Copy link

dkumor commented Feb 16, 2019

Suppose the following folder structure:

test.txt
folder1/
   test2.txt

By default, http.File.Readdir in golang returns direct child files, so gives [test.txt, folder1/]

However, when I pack the files, File.Readdir seems to perform a recursive directory listing, and returns [test.txt,folder1,test2.txt] Note that test2.txt behaves as if it were in the root folder.

This causes issues in code using Readdir to recursively copy a directory from an embedded filesystem, and causes http.FileServer to give an incorrect listing when served without index.html

This issue is caused by https://github.com/rakyll/statik/blob/master/fs/fs.go#L163 , which does not check whether the file is in a subpath.

On a related note, empty directories are not listed at all, meaning that it would seem like they are non-existent.

@dkumor
Copy link
Author

dkumor commented Feb 16, 2019

Just noticed there is already a PR for this at #55

@dkumor
Copy link
Author

dkumor commented Mar 20, 2019

Fixed in #61

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

Successfully merging a pull request may close this issue.

1 participant