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 not guardable (can fail even when fileExists succeeds) #11917

Open
cmahnke opened this issue Jan 25, 2024 · 2 comments
Open

readDir not guardable (can fail even when fileExists succeeds) #11917

cmahnke opened this issue Jan 25, 2024 · 2 comments
Labels
Milestone

Comments

@cmahnke
Copy link

cmahnke commented Jan 25, 2024

What version of Hugo are you using (hugo version)?

hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended darwin/arm64 BuildDate=2024-01-05T12:21:15Z VendorInfo=brew

Does this issue reproduce with the latest release?

Yes

Description

fileExists and os.Stat report a file as existing but readDir fails, maybe the virtual filesystem doesn't apply to readDir?

I haven't test with mounts, but my expectation that either none should work or all.

See https://github.com/cmahnke/hugo-test
The template is in layouts/partials/dir-check.html

@cmahnke
Copy link
Author

cmahnke commented Jan 26, 2024

Trying to use this in https://github.com/cmahnke/hugo-test/blob/main/layouts/partials/dir-check.html#L5

{{- with $codes := readDir $siteDir -}}
  {{- $siteShortcodes = $codes -}}
{{- end -}}

Doesn't help either.

@cmahnke
Copy link
Author

cmahnke commented Jan 26, 2024

The problem seems to be introduced in tpl/os/os.go

The are two variables with filesystem references readFileFs and workFs. readDir operates on workFs while os.Stat and fileExists operate on readFileFs. The later seems to be the union file system composed of the current directory, the theme directory and certainly configured mounts.

Since not even readFile operates on workFs I strongly assume that this is not intentional.

@bep bep added this to the v0.130.0 milestone Jul 22, 2024
@bep bep removed the NeedsTriage label Jul 22, 2024
@bep bep modified the milestones: v0.130.0, v0.131.0 Jul 30, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants