ipfs / ipfs/boxo

[ipfs/go-ipfs-files] Possibility WriteTo to exist dir

Open
#28 3 comments 0 reactions 0 assignees View on GitHub
need/triage
Dominant language
Go
Stars
316
Forks
163
Avg merge
4d 12h
Merged PRs (30d)
8

Description

Maybe add to function `WriteTo` the feature for write to exist directory?

two choices:
1. Change exist function:

```go
// WriteTo writes the given node to the local filesystem at fpath.
func WriteTo(nd Node, fpath string, toExist bool) error {
switch nd := nd.(type) {
...
case Directory:
err := os.Mkdir(fpath, os.ModePerm)

switch {
case errors.Is(err, os.ErrExist):

case err != nil:
return err
}
...
```

2. Add a function with an additional argument `ignoreExist` or something else. Use exist fucntion `WriteTo` like a wrapper:

```go
// WriteTo writes the given node to the local filesystem at fpath.
func WriteTo(nd Node, fpath string) error {
return WriteToWithParams(nd, fpath, false)
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.