Skip to content

Commit

Permalink
Merge pull request #9 from paradeum-team/yuan
Browse files Browse the repository at this point in the history
fix some bugs.
  • Loading branch information
freedomiris authored Jun 12, 2023
2 parents 8b84ba2 + 2a13334 commit 09e9ab5
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 16 deletions.
10 changes: 4 additions & 6 deletions MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ gcscmd config
The `get` command allows you to retrieve an object from the system. Use the following syntax:

```shell
gcscmd get cs://<BUCKET> [--name=<name>] [--cid=<cid>]
gcscmd get cs://<BUCKET> [--name=<name>] [--cid=<cid>] [--downloadfolder=<downloadfolder>] [flags]
```

Replace `<BUCKET>` with the name of the bucket where the object is located. You can optionally specify the name or CID of the object using the `--name` or `--cid` flags, respectively.
Expand All @@ -77,6 +77,7 @@ Replace `<BUCKET>` with the name of the bucket where the object is located. You

- `-c, --cid <cid>`: The CID of the object you want to retrieve.
- `-n, --name <name>`: The name of the object you want to retrieve.
- `-d, --downloadfolder <downloadfolder>`: The folder of download.

#### Example

Expand Down Expand Up @@ -142,7 +143,8 @@ To manage and show logs of the running daemon, use the following command:
gcscmd log <level>
```

Replace `<level>` with the desired log level, such as `debug`, `info`, `warn`, or `error`.
Replace `<level>` with the desired log level, such as `trace`, `debug`, `info`, `warn`, or `error`.


This command will manage and display logs of the specified log level.

Expand Down Expand Up @@ -597,7 +599,3 @@ The logger configuration allows you to specify various settings related to loggi
- Description: The name of the log file.
- Type: String
- Default Value: `chainstorage-cli-log`




2 changes: 1 addition & 1 deletion cmd/getCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

// getCmd represents the get command
var getCmd = &cobra.Command{
Use: "get cs://BUCKET [--name=<name>] [--cid=<cid>]",
Use: "get cs://BUCKET [--name=<name>] [--cid=<cid>] [--downloadfolder=<downloadfolder>]",
Short: "get object",
Long: `get object`,
Run: func(cmd *cobra.Command, args []string) {
Expand Down
10 changes: 6 additions & 4 deletions cmd/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,12 @@ func objectRemoveRun(cmd *cobra.Command, args []string) {

count := respObjectList.Data.Count
if count == 1 {
// todo:模糊匹配还是精准匹配?
rawObjectName := respObjectList.Data.List[0].ObjectName
if !force && rawObjectName != objectName {
Error(cmd, args, sdkcode.ErrObjectNotFound)
if len(objectName) != 0 {
// todo:模糊匹配还是精准匹配?
rawObjectName := respObjectList.Data.List[0].ObjectName
if !force && rawObjectName != objectName {
Error(cmd, args, sdkcode.ErrObjectNotFound)
}
}

objectId := respObjectList.Data.List[0].Id
Expand Down
21 changes: 19 additions & 2 deletions cmd/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/paradeum-team/chainstorage-sdk/model"
"github.com/spf13/cobra"
"os"
"strings"
"text/template"
)

Expand Down Expand Up @@ -52,15 +53,31 @@ func versionRun(cmd *cobra.Command, args []string) {

func versionRunOutput(cmd *cobra.Command, args []string, versionInfo *VersionInfo) {
templateContent := `
Client Version: version.Info{Version:"v{{.Version}}"}
Server Version: version.Info{Version:"v{{.ApiVersion}}"}
Client Version: version.Info{Version:"{{.Version}}"}
Server Version: version.Info{Version:"{{.ApiVersion}}"}
`

t, err := template.New("versionTemplate").Parse(templateContent)
if err != nil {
Error(cmd, args, err)
}

clientVersion := versionInfo.Version
clientVersion = strings.ToLower(clientVersion)
if !strings.HasPrefix(clientVersion, "v") {
clientVersion = "v" + clientVersion
}
versionInfo.Version = clientVersion

apiVersion := versionInfo.ApiVersion
apiVersion = strings.ToLower(apiVersion)
if !strings.HasPrefix(apiVersion, "v") && apiVersion != "latest" {
apiVersion = "v" + apiVersion
}
apiVersion = strings.TrimSuffix(apiVersion, "\r")
apiVersion = strings.TrimSuffix(apiVersion, "\n")
versionInfo.ApiVersion = apiVersion

err = t.Execute(os.Stdout, versionInfo)
if err != nil {
Error(cmd, args, err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/versionCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
// versionCmd represents the version command
var versionCmd = &cobra.Command{
Use: "version",
Short: "Show IPFS version information",
Long: `Show IPFS version information`,
Short: "Show gcscmd version information",
Long: `Show gcscmd version information`,
Run: func(cmd *cobra.Command, args []string) {
//fmt.Println("version called")
versionRun(cmd, args)
Expand Down
2 changes: 1 addition & 1 deletion config.toml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
ipfsGateway = "chainstorage-gateway.solarfs.io/ipfs/"
useHttpsProtocol = true
bucketPrefix = 'cs://'
listOffset = 20
listOffset = 10
cleanTmpData = true
maxRetries = 3
retryDelay = 3
Expand Down

0 comments on commit 09e9ab5

Please sign in to comment.