have a typed importID

This commit is contained in:
aarshkshah1992
2021-07-07 12:02:48 +05:30
parent 2b5164c956
commit ba236fe258
14 changed files with 43 additions and 2333 deletions
+3 -3
View File
@@ -513,7 +513,7 @@ func (a *API) ClientImport(ctx context.Context, ref api.FileRef) (res *api.Impor
}, nil
}
func (a *API) ClientRemoveImport(ctx context.Context, importID uint64) error {
func (a *API) ClientRemoveImport(ctx context.Context, importID importmgr.ImportID) error {
info, err := a.imgr().Info(importID)
if err != nil {
return xerrors.Errorf("failed to fetch import info: %w", err)
@@ -529,7 +529,7 @@ func (a *API) ClientRemoveImport(ctx context.Context, importID uint64) error {
func (a *API) ClientImportLocal(ctx context.Context, r io.Reader) (cid.Cid, error) {
// write payload to temp file
tmpPath, err := a.imgr().NewTempFile(rand.Uint64())
tmpPath, err := a.imgr().NewTempFile(importmgr.ImportID(rand.Uint64()))
if err != nil {
return cid.Undef, err
}
@@ -1037,7 +1037,7 @@ func (a *API) ClientDealPieceCID(ctx context.Context, root cid.Cid) (api.DataCID
}
func (a *API) ClientGenCar(ctx context.Context, ref api.FileRef, outputPath string) error {
id := rand.Uint64()
id := importmgr.ImportID(rand.Uint64())
tmpCARv2File, err := a.imgr().NewTempFile(id)
if err != nil {
return xerrors.Errorf("failed to create temp file: %w", err)
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"os"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/node/repo/importmgr"
"github.com/ipfs/go-blockservice"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-cidutil"
@@ -24,7 +25,7 @@ import (
)
// importNormalFileToCARv2 transforms the client's "normal file" to a Unixfs IPLD DAG and writes out the DAG to a CARv2 file at the given output path.
func (a *API) importNormalFileToCARv2(ctx context.Context, importID uint64, inputFilePath string, outputCARv2Path string) (c cid.Cid, finalErr error) {
func (a *API) importNormalFileToCARv2(ctx context.Context, importID importmgr.ImportID, inputFilePath string, outputCARv2Path string) (c cid.Cid, finalErr error) {
// TODO: We've currently put in a hack to create the Unixfs DAG as a CARv2 without using Badger.
// We first transform the Unixfs DAG to a rootless CARv2 file as CARv2 doesen't allow streaming writes without specifying the root upfront and we