diff --git a/cmd/download.go b/cmd/download.go index 29772825..e260b396 100644 --- a/cmd/download.go +++ b/cmd/download.go @@ -1,6 +1,7 @@ package cmd import ( + "context" "encoding/json" "os" "strings" @@ -161,6 +162,38 @@ var downloadCmd = &cobra.Command{ os.Exit(1) } + meta, err := allocationObj.GetFileMeta(remotePath) + if err != nil { + PrintError("Error getting file meta", err) + os.Exit(1) + } + if meta.Type == fileref.DIRECTORY { + if meta.CustomMeta == "" { + PrintError("Use downloaddir command to download directory") + os.Exit(1) + } + customMetaMap := make(map[string]string) + err = json.Unmarshal([]byte(meta.CustomMeta), &customMetaMap) + if err != nil { + PrintError("Error unmarshalling custom meta", err) + os.Exit(1) + } + if customMetaMap["large_file"] != "" { + fh, err := os.Create(localPath) + if err != nil { + PrintError("Error creating the file", err) + os.Exit(1) + } + defer fh.Close() + err = allocationObj.DownloadLargeFile(context.Background(), fh, remotePath, "", statusBar) + if err != nil { + PrintError("Error downloading the file", err) + os.Exit(1) + } else { + return + } + } + } if thumbnail { errE = allocationObj.DownloadThumbnail(localPath, remotePath, verifyDownload, statusBar, true) } else { diff --git a/go.mod b/go.mod index ca4f03e9..84f3281e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.22.5 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.19.4-0.20250214122330-072b85b3c09b + github.com/0chain/gosdk v1.19.7-0.20250221092102-ee7dc15762b6 github.com/icza/bitio v1.1.0 github.com/olekukonko/tablewriter v0.0.5 github.com/spf13/cobra v1.6.0 @@ -86,4 +86,4 @@ require ( ) // temporary, for development -//replace github.com/0chain/gosdk => ../gosdk +// replace github.com/0chain/gosdk => ../gosdk diff --git a/go.sum b/go.sum index eedeea9c..867a5aaa 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI= github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw= github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM= github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc= -github.com/0chain/gosdk v1.19.4-0.20250214122330-072b85b3c09b h1:Pdrc+WZqBuT3vcT1JNZRFM7L1Lh4OUoaMz6VW9Uo5k8= -github.com/0chain/gosdk v1.19.4-0.20250214122330-072b85b3c09b/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw= +github.com/0chain/gosdk v1.19.7-0.20250221092102-ee7dc15762b6 h1:TDBbQXiTll3ByOmaWTlITuUQ/ZCXnpQxxq97Sidf0fs= +github.com/0chain/gosdk v1.19.7-0.20250221092102-ee7dc15762b6/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=