Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions cmd/download.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"context"
"encoding/json"
"os"
"strings"
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,4 +86,4 @@ require (
)

// temporary, for development
//replace github.com/0chain/gosdk => ../gosdk
// replace github.com/0chain/gosdk => ../gosdk
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Loading