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

Util: fix mkdir for trailing slashes #3514

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

mtzguido
Copy link
Member

@mtzguido mtzguido commented Oct 2, 2024

When calling F* as in

$ fstar.exe --cache_dir a/b/
wrong argument given to option `cache_dir`

when a does not yet exist, F* is supposed to attempt to create the directory, but it fails due to the trailing slash. The problem is that when mkdir raises an ENOENT, we attempt to create parent directories, but we are computing the parent of 'a/b/' to be 'a/b' (since we naively removed the last slash component). So the process is:

  • Try to mkdir a/b/, get ENOENT
  • Try to mkdir a/b, get ENOENT
  • Try to mkdir a, works
  • Retry mkdir a/b, works
  • Retry mkdir a/b/, fails since it already exists.

This fixes the problem ignoring trailing slashes. Moving to a full, F*-based filename library would be a lot better.

When calling F* as in
```
$ fstar.exe --cache_dir a/b/
wrong argument given to option `cache_dir`
```
when `a` does not yet exist, F* is supposed to attempt to create the
directory, but it fails due to the trailing slash. The problem is that
when mkdir raises an ENOENT, we attempt to create parent directories,
but we are computing the parent of 'a/b/' to be 'a/b' (since we naively
removed the last slash component). So the process is:

- Try to mkdir a/b/, get ENOENT
- Try to mkdir a/b, get ENOENT
- Try to mkdir a, works
- Retry mkdir a/b, works
- Retry mkdir a/b/, fails since it already exists.

This fixes the problem ignoring trailing slashes. Moving to a full,
F*-based filename library would be a lot better.
@mtzguido mtzguido enabled auto-merge October 2, 2024 20:38
@mtzguido mtzguido merged commit 55e1119 into FStarLang:master Oct 2, 2024
2 checks passed
@mtzguido mtzguido deleted the mkdir branch October 2, 2024 20:50
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 this pull request may close these issues.

1 participant