go-git / go-billy

The missing interface filesystem abstraction for Go
https://pkg.go.dev/github.com/go-git/go-billy/v5
Apache License 2.0
324 stars 43 forks source link

Support for limits on `memfs`? #64

Open evankanderson opened 5 months ago

evankanderson commented 5 months ago

We're using memfs alongside go-git to perform a shallow clone of Git repositories. We'd like to be able to limit the data written to the memfs (other than heap memory / crashing).

Would additions to the memfs interface to support limiting the filesystem contents be of interest / accepted?

pjbgf commented 5 months ago

Hey @evankanderson, thanks for creating your first issue.

Here's a discussion around the topic of limiting storage. Overall, I am not opposed to having this capability, we just need to ensure the user experience is solid. The question is what precisely are we going to limit and how are we going to enforce it?

I am happy to review a PR on this if you are keen to propose one.

evankanderson commented 5 months ago

I'm willing to look at a filter option for go-git as well, but I'll see about sending a PR to add upper bounds on total file size and total number of files to memfs.

Is it expected that memfs is thread-safe? (I'm assuming not given current code)

pjbgf commented 5 months ago

Is it expected that memfs is thread-safe?

It isn't at the moment, and is one of the causes of go-git's thread-safety problems. That is something I would also be happy to review a separate PR for. As this could have an impact on performance, I would just make sure it is something folks can opt-in/out.