ipfs / boxo

A set of reference libraries for building IPFS applications and implementations in Go.
https://github.com/ipfs/boxo#readme
Other
213 stars 95 forks source link

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

Open lasiar opened 3 years ago

lasiar commented 3 years ago

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

two choices:

  1. Change exist function:
// 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
        }
        ...
  1. Add a function with an additional argument ignoreExist or something else. Use exist fucntion WriteTo like a wrapper:
// WriteTo writes the given node to the local filesystem at fpath.
func WriteTo(nd Node, fpath string) error {
    return WriteToWithParams(nd, fpath, false)
}
welcome[bot] commented 3 years ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

welcome[bot] commented 1 year ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

ofman commented 11 months ago

This is a similar issue I have posted here: https://github.com/ipfs/boxo/issues/520

As a bonus some kind of return int64 progress would be great too please. Thanks! :)

P.S. For example func fileArchive(f files.Node, name string, archive bool, compression int) (io.ReadCloser, error) {} function has io.ReadCloser in kubo/core/commands/get.go. Also there are archive bool, compression int arguments which are not present in boxo/files/filewriter.go func WriteTo(nd Node, fpath string) error {} function which only returns error.