Skip to content

Commit f6c6327

Browse files
authored
Merge pull request ipfs#5612 from overbool/refactor/use-int64
refactor(command): modify int to int64
2 parents cffcc8e + ff6f16c commit f6c6327

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

core/commands/cat.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{
2929
cmdkit.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
3030
},
3131
Options: []cmdkit.Option{
32-
cmdkit.IntOption(offsetOptionName, "o", "Byte offset to begin reading from."),
33-
cmdkit.IntOption(lengthOptionName, "l", "Maximum number of bytes to read."),
32+
cmdkit.Int64Option(offsetOptionName, "o", "Byte offset to begin reading from."),
33+
cmdkit.Int64Option(lengthOptionName, "l", "Maximum number of bytes to read."),
3434
},
3535
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
3636
node, err := cmdenv.GetNode(env)
@@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{
4949
}
5050
}
5151

52-
offset, _ := req.Options[offsetOptionName].(int)
52+
offset, _ := req.Options[offsetOptionName].(int64)
5353
if offset < 0 {
5454
return fmt.Errorf("cannot specify negative offset")
5555
}
5656

57-
max, found := req.Options[lengthOptionName].(int)
57+
max, found := req.Options[lengthOptionName].(int64)
5858
if err != nil {
5959
return err
6060
}

core/commands/files.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ Examples:
564564
cmdkit.StringArg("path", true, false, "Path to file to be read."),
565565
},
566566
Options: []cmdkit.Option{
567-
cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
568-
cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
567+
cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
568+
cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
569569
},
570570
Run: func(req oldcmds.Request, res oldcmds.Response) {
571571
n, err := req.InvocContext().GetNode()
@@ -600,7 +600,7 @@ Examples:
600600

601601
defer rfd.Close()
602602

603-
offset, _, err := req.Option(offsetOptionName).Int()
603+
offset, _, err := req.Option(offsetOptionName).Int64()
604604
if err != nil {
605605
res.SetError(err, cmdkit.ErrNormal)
606606
return
@@ -628,7 +628,7 @@ Examples:
628628
}
629629

630630
var r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context()}
631-
count, found, err := req.Option(filesCountOptionName).Int()
631+
count, found, err := req.Option(filesCountOptionName).Int64()
632632
if err != nil {
633633
res.SetError(err, cmdkit.ErrNormal)
634634
return
@@ -750,11 +750,11 @@ stat' on the file or any of its ancestors.
750750
cmdkit.FileArg("data", true, false, "Data to write.").EnableStdin(),
751751
},
752752
Options: []cmdkit.Option{
753-
cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
753+
cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
754754
cmdkit.BoolOption(filesCreateOptionName, "e", "Create the file if it does not exist."),
755755
cmdkit.BoolOption(filesParentsOptionName, "p", "Make parent directories as needed."),
756756
cmdkit.BoolOption(filesTruncateOptionName, "t", "Truncate the file to size zero before writing."),
757-
cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
757+
cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
758758
cmdkit.BoolOption(filesRawLeavesOptionName, "Use raw blocks for newly created leaf nodes. (experimental)"),
759759
cidVersionOption,
760760
hashOption,
@@ -781,7 +781,7 @@ stat' on the file or any of its ancestors.
781781
return err
782782
}
783783

784-
offset, _ := req.Options[filesOffsetOptionName].(int)
784+
offset, _ := req.Options[filesOffsetOptionName].(int64)
785785
if offset < 0 {
786786
return fmt.Errorf("cannot have negative write offset")
787787
}
@@ -823,7 +823,7 @@ stat' on the file or any of its ancestors.
823823
}
824824
}
825825

826-
count, countfound := req.Options[filesCountOptionName].(int)
826+
count, countfound := req.Options[filesCountOptionName].(int64)
827827
if countfound && count < 0 {
828828
return fmt.Errorf("cannot have negative byte count")
829829
}

0 commit comments

Comments
 (0)