Merge pull request #14921 from aaronlehmann/int64

Fix uses of "int" where "int64" should be used instead
This commit is contained in:
Arnaud Porterie 2015-08-04 19:16:13 -07:00
commit 4c56c9f9ba
4 changed files with 16 additions and 16 deletions

View file

@ -23,8 +23,8 @@ func (e *JSONError) Error() string {
type JSONProgress struct { type JSONProgress struct {
terminalFd uintptr terminalFd uintptr
Current int `json:"current,omitempty"` Current int64 `json:"current,omitempty"`
Total int `json:"total,omitempty"` Total int64 `json:"total,omitempty"`
Start int64 `json:"start,omitempty"` Start int64 `json:"start,omitempty"`
} }
@ -64,7 +64,7 @@ func (p *JSONProgress) String() string {
numbersBox = fmt.Sprintf("%8v/%v", current, total) numbersBox = fmt.Sprintf("%8v/%v", current, total)
if p.Current > 0 && p.Start > 0 && percentage < 50 { 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) perEntry := fromStart / time.Duration(p.Current)
left := time.Duration(p.Total-p.Current) * perEntry left := time.Duration(p.Total-p.Current) * perEntry
left = (left / time.Second) * time.Second left = (left / time.Second) * time.Second

View file

@ -14,9 +14,9 @@ type Config struct {
In io.ReadCloser // Stream to read from In io.ReadCloser // Stream to read from
Out io.Writer // Where to send progress bar to Out io.Writer // Where to send progress bar to
Formatter *streamformatter.StreamFormatter Formatter *streamformatter.StreamFormatter
Size int Size int64
Current int Current int64
LastUpdate int LastUpdate int64
NewLines bool NewLines bool
ID string ID string
Action string Action string
@ -29,11 +29,11 @@ func New(newReader Config) *Config {
func (config *Config) Read(p []byte) (n int, err error) { func (config *Config) Read(p []byte) (n int, err error) {
read, err := config.In.Read(p) read, err := config.In.Read(p)
config.Current += read config.Current += int64(read)
updateEvery := 1024 * 512 //512kB updateEvery := int64(1024 * 512) //512kB
if config.Size > 0 { if config.Size > 0 {
// Update progress for every 1% read if 1% < 512kB // 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 updateEvery = increment
} }
} }

View file

@ -20,7 +20,7 @@ func TestOutputOnPrematureClose(t *testing.T) {
In: reader, In: reader,
Out: writer, Out: writer,
Formatter: streamformatter.NewStreamFormatter(), Formatter: streamformatter.NewStreamFormatter(),
Size: len(content), Size: int64(len(content)),
NewLines: true, NewLines: true,
ID: "Test", ID: "Test",
Action: "Read", Action: "Read",
@ -60,7 +60,7 @@ func TestCompleteSilently(t *testing.T) {
In: reader, In: reader,
Out: writer, Out: writer,
Formatter: streamformatter.NewStreamFormatter(), Formatter: streamformatter.NewStreamFormatter(),
Size: len(content), Size: int64(len(content)),
NewLines: true, NewLines: true,
ID: "Test", ID: "Test",
Action: "Read", Action: "Read",

View file

@ -95,17 +95,17 @@ func (f tarHeaderSelectFunc) selectHeaders(h *tar.Header) (orderedHeaders [][2]s
func v0TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) { func v0TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) {
return [][2]string{ return [][2]string{
{"name", h.Name}, {"name", h.Name},
{"mode", strconv.Itoa(int(h.Mode))}, {"mode", strconv.FormatInt(h.Mode, 10)},
{"uid", strconv.Itoa(h.Uid)}, {"uid", strconv.Itoa(h.Uid)},
{"gid", strconv.Itoa(h.Gid)}, {"gid", strconv.Itoa(h.Gid)},
{"size", strconv.Itoa(int(h.Size))}, {"size", strconv.FormatInt(h.Size, 10)},
{"mtime", strconv.Itoa(int(h.ModTime.UTC().Unix()))}, {"mtime", strconv.FormatInt(h.ModTime.UTC().Unix(), 10)},
{"typeflag", string([]byte{h.Typeflag})}, {"typeflag", string([]byte{h.Typeflag})},
{"linkname", h.Linkname}, {"linkname", h.Linkname},
{"uname", h.Uname}, {"uname", h.Uname},
{"gname", h.Gname}, {"gname", h.Gname},
{"devmajor", strconv.Itoa(int(h.Devmajor))}, {"devmajor", strconv.FormatInt(h.Devmajor, 10)},
{"devminor", strconv.Itoa(int(h.Devminor))}, {"devminor", strconv.FormatInt(h.Devminor, 10)},
} }
} }