Merge pull request #14921 from aaronlehmann/int64
Fix uses of "int" where "int64" should be used instead
This commit is contained in:
commit
4c56c9f9ba
4 changed files with 16 additions and 16 deletions
|
@ -23,8 +23,8 @@ func (e *JSONError) Error() string {
|
|||
|
||||
type JSONProgress struct {
|
||||
terminalFd uintptr
|
||||
Current int `json:"current,omitempty"`
|
||||
Total int `json:"total,omitempty"`
|
||||
Current int64 `json:"current,omitempty"`
|
||||
Total int64 `json:"total,omitempty"`
|
||||
Start int64 `json:"start,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (p *JSONProgress) String() string {
|
|||
numbersBox = fmt.Sprintf("%8v/%v", current, total)
|
||||
|
||||
if p.Current > 0 && p.Start > 0 && percentage < 50 {
|
||||
fromStart := time.Now().UTC().Sub(time.Unix(int64(p.Start), 0))
|
||||
fromStart := time.Now().UTC().Sub(time.Unix(p.Start, 0))
|
||||
perEntry := fromStart / time.Duration(p.Current)
|
||||
left := time.Duration(p.Total-p.Current) * perEntry
|
||||
left = (left / time.Second) * time.Second
|
||||
|
|
|
@ -14,9 +14,9 @@ type Config struct {
|
|||
In io.ReadCloser // Stream to read from
|
||||
Out io.Writer // Where to send progress bar to
|
||||
Formatter *streamformatter.StreamFormatter
|
||||
Size int
|
||||
Current int
|
||||
LastUpdate int
|
||||
Size int64
|
||||
Current int64
|
||||
LastUpdate int64
|
||||
NewLines bool
|
||||
ID string
|
||||
Action string
|
||||
|
@ -29,11 +29,11 @@ func New(newReader Config) *Config {
|
|||
|
||||
func (config *Config) Read(p []byte) (n int, err error) {
|
||||
read, err := config.In.Read(p)
|
||||
config.Current += read
|
||||
updateEvery := 1024 * 512 //512kB
|
||||
config.Current += int64(read)
|
||||
updateEvery := int64(1024 * 512) //512kB
|
||||
if config.Size > 0 {
|
||||
// Update progress for every 1% read if 1% < 512kB
|
||||
if increment := int(0.01 * float64(config.Size)); increment < updateEvery {
|
||||
if increment := int64(0.01 * float64(config.Size)); increment < updateEvery {
|
||||
updateEvery = increment
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestOutputOnPrematureClose(t *testing.T) {
|
|||
In: reader,
|
||||
Out: writer,
|
||||
Formatter: streamformatter.NewStreamFormatter(),
|
||||
Size: len(content),
|
||||
Size: int64(len(content)),
|
||||
NewLines: true,
|
||||
ID: "Test",
|
||||
Action: "Read",
|
||||
|
@ -60,7 +60,7 @@ func TestCompleteSilently(t *testing.T) {
|
|||
In: reader,
|
||||
Out: writer,
|
||||
Formatter: streamformatter.NewStreamFormatter(),
|
||||
Size: len(content),
|
||||
Size: int64(len(content)),
|
||||
NewLines: true,
|
||||
ID: "Test",
|
||||
Action: "Read",
|
||||
|
|
|
@ -95,17 +95,17 @@ func (f tarHeaderSelectFunc) selectHeaders(h *tar.Header) (orderedHeaders [][2]s
|
|||
func v0TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) {
|
||||
return [][2]string{
|
||||
{"name", h.Name},
|
||||
{"mode", strconv.Itoa(int(h.Mode))},
|
||||
{"mode", strconv.FormatInt(h.Mode, 10)},
|
||||
{"uid", strconv.Itoa(h.Uid)},
|
||||
{"gid", strconv.Itoa(h.Gid)},
|
||||
{"size", strconv.Itoa(int(h.Size))},
|
||||
{"mtime", strconv.Itoa(int(h.ModTime.UTC().Unix()))},
|
||||
{"size", strconv.FormatInt(h.Size, 10)},
|
||||
{"mtime", strconv.FormatInt(h.ModTime.UTC().Unix(), 10)},
|
||||
{"typeflag", string([]byte{h.Typeflag})},
|
||||
{"linkname", h.Linkname},
|
||||
{"uname", h.Uname},
|
||||
{"gname", h.Gname},
|
||||
{"devmajor", strconv.Itoa(int(h.Devmajor))},
|
||||
{"devminor", strconv.Itoa(int(h.Devminor))},
|
||||
{"devmajor", strconv.FormatInt(h.Devmajor, 10)},
|
||||
{"devminor", strconv.FormatInt(h.Devminor, 10)},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue