Skip to content

Commit c3684af

Browse files
committed
Change from using hardcoded Prefixes to the more flex able cid.Format type.
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent 3296412 commit c3684af

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

core/commands/add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ You can now check what blocks have been created by:
285285
md := dagtest.Mock()
286286
emptyDirNode := ft.EmptyDirNode()
287287
// Use the same prefix for the "empty" MFS root as for the file adder.
288-
emptyDirNode.Prefix = *fileAdder.Prefix
288+
emptyDirNode.SetPrefix(fileAdder.Prefix)
289289
mr, err := mfs.NewRoot(req.Context, md, emptyDirNode, nil)
290290
if err != nil {
291291
res.SetError(err, cmdkit.ErrNormal)

core/commands/files.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ Change the cid version or hash function of the root node of a given path.
958958
},
959959
}
960960

961-
func updatePath(rt *mfs.Root, pth string, prefix *cid.Prefix, flush bool) error {
961+
func updatePath(rt *mfs.Root, pth string, prefix cid.Builder, flush bool) error {
962962
if prefix == nil {
963963
return nil
964964
}
@@ -1088,7 +1088,7 @@ Remove files or directories.
10881088
},
10891089
}
10901090

1091-
func getPrefixNew(req *cmds.Request) (*cid.Prefix, error) {
1091+
func getPrefixNew(req *cmds.Request) (cid.Builder, error) {
10921092
cidVer, cidVerSet := req.Options["cid-version"].(int)
10931093
hashFunStr, hashFunSet := req.Options["hash"].(string)
10941094

@@ -1117,7 +1117,7 @@ func getPrefixNew(req *cmds.Request) (*cid.Prefix, error) {
11171117
return &prefix, nil
11181118
}
11191119

1120-
func getPrefix(req oldcmds.Request) (*cid.Prefix, error) {
1120+
func getPrefix(req oldcmds.Request) (cid.Builder, error) {
11211121
cidVer, cidVerSet, _ := req.Option("cid-version").Int()
11221122
hashFunStr, hashFunSet, _ := req.Option("hash").String()
11231123

@@ -1146,7 +1146,7 @@ func getPrefix(req oldcmds.Request) (*cid.Prefix, error) {
11461146
return &prefix, nil
11471147
}
11481148

1149-
func getFileHandle(r *mfs.Root, path string, create bool, prefix *cid.Prefix) (*mfs.File, error) {
1149+
func getFileHandle(r *mfs.Root, path string, create bool, prefix cid.Builder) (*mfs.File, error) {
11501150
target, err := mfs.Lookup(r, path)
11511151
switch err {
11521152
case nil:

core/coreunix/add.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ type Adder struct {
8989
mroot *mfs.Root
9090
unlocker bstore.Unlocker
9191
tempRoot *cid.Cid
92-
Prefix *cid.Prefix
92+
Prefix cid.Builder
9393
liveNodes uint64
9494
}
9595

mfs/dir.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ func NewDirectory(ctx context.Context, name string, node ipld.Node, parent child
6464
}
6565

6666
// GetPrefix gets the CID prefix of the root node
67-
func (d *Directory) GetPrefix() *cid.Prefix {
67+
func (d *Directory) GetPrefix() cid.Builder {
6868
return d.unixfsDir.GetPrefix()
6969
}
7070

7171
// SetPrefix sets the CID prefix
72-
func (d *Directory) SetPrefix(prefix *cid.Prefix) {
72+
func (d *Directory) SetPrefix(prefix cid.Builder) {
7373
d.unixfsDir.SetPrefix(prefix)
7474
}
7575

mfs/ops.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func PutNode(r *Root, path string, nd ipld.Node) error {
101101
type MkdirOpts struct {
102102
Mkparents bool
103103
Flush bool
104-
Prefix *cid.Prefix
104+
Prefix cid.Builder
105105
}
106106

107107
// Mkdir creates a directory at 'path' under the directory 'd', creating

0 commit comments

Comments
 (0)