From ff6f16c939e264c12884a424caec658e44236bcf Mon Sep 17 00:00:00 2001 From: Overbool Date: Thu, 18 Oct 2018 23:33:05 +0800 Subject: [PATCH] refactor(command): modify int to int64 License: MIT Signed-off-by: Overbool --- core/commands/cat.go | 8 ++++---- core/commands/files.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/commands/cat.go b/core/commands/cat.go index 9456a39d8..6ca60113c 100644 --- a/core/commands/cat.go +++ b/core/commands/cat.go @@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{ cmdkit.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted.").EnableStdin(), }, Options: []cmdkit.Option{ - cmdkit.IntOption(offsetOptionName, "o", "Byte offset to begin reading from."), - cmdkit.IntOption(lengthOptionName, "l", "Maximum number of bytes to read."), + cmdkit.Int64Option(offsetOptionName, "o", "Byte offset to begin reading from."), + cmdkit.Int64Option(lengthOptionName, "l", "Maximum number of bytes to read."), }, Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error { node, err := cmdenv.GetNode(env) @@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{ } } - offset, _ := req.Options[offsetOptionName].(int) + offset, _ := req.Options[offsetOptionName].(int64) if offset < 0 { return fmt.Errorf("cannot specify negative offset") } - max, found := req.Options[lengthOptionName].(int) + max, found := req.Options[lengthOptionName].(int64) if err != nil { return err } diff --git a/core/commands/files.go b/core/commands/files.go index 22651f427..cc7bc4be2 100644 --- a/core/commands/files.go +++ b/core/commands/files.go @@ -564,8 +564,8 @@ Examples: cmdkit.StringArg("path", true, false, "Path to file to be read."), }, Options: []cmdkit.Option{ - cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin reading from."), - cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."), + cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin reading from."), + cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."), }, Run: func(req oldcmds.Request, res oldcmds.Response) { n, err := req.InvocContext().GetNode() @@ -600,7 +600,7 @@ Examples: defer rfd.Close() - offset, _, err := req.Option(offsetOptionName).Int() + offset, _, err := req.Option(offsetOptionName).Int64() if err != nil { res.SetError(err, cmdkit.ErrNormal) return @@ -628,7 +628,7 @@ Examples: } var r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context()} - count, found, err := req.Option(filesCountOptionName).Int() + count, found, err := req.Option(filesCountOptionName).Int64() if err != nil { res.SetError(err, cmdkit.ErrNormal) return @@ -750,11 +750,11 @@ stat' on the file or any of its ancestors. cmdkit.FileArg("data", true, false, "Data to write.").EnableStdin(), }, Options: []cmdkit.Option{ - cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin writing at."), + cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin writing at."), cmdkit.BoolOption(filesCreateOptionName, "e", "Create the file if it does not exist."), cmdkit.BoolOption(filesParentsOptionName, "p", "Make parent directories as needed."), cmdkit.BoolOption(filesTruncateOptionName, "t", "Truncate the file to size zero before writing."), - cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."), + cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."), cmdkit.BoolOption(filesRawLeavesOptionName, "Use raw blocks for newly created leaf nodes. (experimental)"), cidVersionOption, hashOption, @@ -781,7 +781,7 @@ stat' on the file or any of its ancestors. return err } - offset, _ := req.Options[filesOffsetOptionName].(int) + offset, _ := req.Options[filesOffsetOptionName].(int64) if offset < 0 { return fmt.Errorf("cannot have negative write offset") } @@ -823,7 +823,7 @@ stat' on the file or any of its ancestors. } } - count, countfound := req.Options[filesCountOptionName].(int) + count, countfound := req.Options[filesCountOptionName].(int64) if countfound && count < 0 { return fmt.Errorf("cannot have negative byte count") }