diff --git a/importer/balanced/builder.go b/importer/balanced/builder.go index 55b9ccb36..1f6b7e674 100644 --- a/importer/balanced/builder.go +++ b/importer/balanced/builder.go @@ -123,7 +123,7 @@ import ( func Layout(db *h.DagBuilderHelper) (ipld.Node, error) { if db.Done() { // No data, return just an empty node. - root, err := db.NewLeafNode(nil) + root, err := db.NewLeafNode(nil, ft.TFile) if err != nil { return nil, err } @@ -137,7 +137,7 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) { // (corner case), after that subsequent `root` nodes will // always be internal nodes (with a depth > 0) that can // be handled by the loop. - root, fileSize, err := db.NewLeafDataNode() + root, fileSize, err := db.NewLeafDataNode(ft.TFile) if err != nil { return nil, err } @@ -224,7 +224,7 @@ func fillNodeRec(db *h.DagBuilderHelper, node *h.FSNodeOverDag, depth int) (fill if depth == 1 { // Base case: add leaf node with data. - childNode, childFileSize, err = db.NewLeafDataNode() + childNode, childFileSize, err = db.NewLeafDataNode(ft.TFile) if err != nil { return nil, 0, err } diff --git a/importer/helpers/dagbuilder.go b/importer/helpers/dagbuilder.go index 4c897fd48..90c928220 100644 --- a/importer/helpers/dagbuilder.go +++ b/importer/helpers/dagbuilder.go @@ -187,7 +187,7 @@ func (db *DagBuilderHelper) NewLeaf(data []byte) (*UnixfsNode, error) { // NewLeafNode is a variation from `NewLeaf` (see its description) that // returns an `ipld.Node` instead. -func (db *DagBuilderHelper) NewLeafNode(data []byte) (ipld.Node, error) { +func (db *DagBuilderHelper) NewLeafNode(data []byte, fsNodeType pb.Data_DataType) (ipld.Node, error) { if len(data) > BlockSizeLimit { return nil, ErrSizeLimitExceeded } @@ -205,7 +205,7 @@ func (db *DagBuilderHelper) NewLeafNode(data []byte) (ipld.Node, error) { } // Encapsulate the data in UnixFS node (instead of a raw node). - fsNodeOverDag := db.NewFSNodeOverDag(ft.TFile) + fsNodeOverDag := db.NewFSNodeOverDag(fsNodeType) fsNodeOverDag.SetFileData(data) node, err := fsNodeOverDag.Commit() if err != nil { @@ -274,7 +274,7 @@ func (db *DagBuilderHelper) GetNextDataNode() (*UnixfsNode, error) { // used to keep track of the DAG file size). The size of the data is // computed here because after that it will be hidden by `NewLeafNode` // inside a generic `ipld.Node` representation. -func (db *DagBuilderHelper) NewLeafDataNode() (node ipld.Node, dataSize uint64, err error) { +func (db *DagBuilderHelper) NewLeafDataNode(fsNodeType pb.Data_DataType) (node ipld.Node, dataSize uint64, err error) { fileData, err := db.Next() if err != nil { return nil, 0, err @@ -282,7 +282,7 @@ func (db *DagBuilderHelper) NewLeafDataNode() (node ipld.Node, dataSize uint64, dataSize = uint64(len(fileData)) // Create a new leaf node containing the file chunk data. - node, err = db.NewLeafNode(fileData) + node, err = db.NewLeafNode(fileData, fsNodeType) if err != nil { return nil, 0, err }