Skip to content

Conversation

jake-ciolek
Copy link
Contributor

The os.RemoveAll() call returns nil if the path doesn't exist. When the rmPath function is called with allowNotFound set to false, it doesn't change the behaviour of the function.

Change the code so if allowNotFound is set to false, we first check whether the file exists. If it doesn't exist, return an error.

Add tests for three relevant cases.

The os.RemoveAll() call returns nil if the path doesn't exist. When the
rmPath function is called with allowNotFound set to false, it doesn't change the
behaviour of the function.

Change the code so if allowNotFound is set to false, we first check
whether the file exists. If it doesn't exist, return an error.

Add tests for three relevant cases.

Signed-off-by: Jakub Ciolek <jakub@ciolek.dev>
@jake-ciolek jake-ciolek force-pushed the with-allow-not-found-bug branch from 908b89d to ce43956 Compare July 23, 2023 13:28
@jake-ciolek
Copy link
Contributor Author

To clarify further, I have stumbled upon this while tinkering with a LLB client.

Reproducer:

func main() {
	bk := llb.Scratch().File(llb.Rm("/not_found", llb.WithAllowNotFound(false)))

	dt, _ := bk.Marshal(context.TODO(), llb.LinuxAmd64)
	llb.WriteTo(dt, os.Stdout)
}

As of 8656037, passing a WithAllowNotFound option doesn't seem to have an effect on the build.

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.

2 participants