Skip to content

Commit

Permalink
ipfs add --pinpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Voker57 committed Mar 2, 2018
1 parent 4761db1 commit f9fb8ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
fstoreCacheOptionName = "fscache"
cidVersionOptionName = "cid-version"
hashOptionName = "hash"
pinPathOptionName = "pinpath"
)

const adderOutChanSize = 8
Expand Down Expand Up @@ -114,6 +115,7 @@ You can now check what blocks have been created by:
cmdkit.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
cmdkit.StringOption(chunkerOptionName, "s", "Chunking algorithm, size-[bytes] or rabin-[min]-[avg]-[max]").WithDefault("size-262144"),
cmdkit.BoolOption(pinOptionName, "Pin this object when adding.").WithDefault(true),
cmdkit.StringOption(pinPathOptionName, "P", "Pin object under this path. Implies --pin=true").WithDefault(""),
cmdkit.BoolOption(rawLeavesOptionName, "Use raw blocks for leaf nodes. (experimental)"),
cmdkit.BoolOption(noCopyOptionName, "Add the file using filestore. Implies raw-leaves. (experimental)"),
cmdkit.BoolOption(fstoreCacheOptionName, "Check the filestore for pre-existing blocks. (experimental)"),
Expand Down Expand Up @@ -172,6 +174,7 @@ You can now check what blocks have been created by:
fscache, _ := req.Options[fstoreCacheOptionName].(bool)
cidVer, cidVerSet := req.Options[cidVersionOptionName].(int)
hashFunStr, _ := req.Options[hashOptionName].(string)
pinPath, _ := req.Options[pinPathOptionName].(string)

// The arguments are subject to the following constraints.
//
Expand Down Expand Up @@ -280,6 +283,11 @@ You can now check what blocks have been created by:
fileAdder.RawLeaves = rawblks
fileAdder.NoCopy = nocopy
fileAdder.Prefix = &prefix
if pinPath == "" {
fileAdder.PinPath = "added/"
} else {
fileAdder.PinPath = pinPath
}

if hash {
md := dagtest.Mock()
Expand Down
5 changes: 3 additions & 2 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type Adder struct {
tempRoot *cid.Cid
Prefix *cid.Prefix
liveNodes uint64
PinPath string
}

func (adder *Adder) mfsRoot() (*mfs.Root, error) {
Expand Down Expand Up @@ -202,14 +203,14 @@ func (adder *Adder) PinRoot() error {
}

if adder.tempRoot != nil {
err := adder.pinning.UnpinCidUnderPrefix("added/", adder.tempRoot, true)
err := adder.pinning.UnpinCidUnderPrefix(adder.PinPath, adder.tempRoot, true)
if err != nil {
return err
}
adder.tempRoot = rnk
}

return adder.pinning.AddPin("added/", rnk, true)
return adder.pinning.AddPin(adder.PinPath, rnk, true)
}

// Finalize flushes the mfs root directory and returns the mfs root node.
Expand Down

1 comment on commit f9fb8ea

@GitCop
Copy link

@GitCop GitCop commented on f9fb8ea Mar 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.