Skip to content

Commit

Permalink
Workaround an issue in golang 1.10.3 where a 4GB file is truncated.
Browse files Browse the repository at this point in the history
  • Loading branch information
AWoloszyn committed Aug 10, 2018
1 parent 0a85956 commit 24f58fd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions gapis/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"runtime/pprof"
Expand Down Expand Up @@ -202,10 +202,26 @@ func (s *server) LoadCapture(ctx context.Context, path string) (*path.Capture, e
return nil, fmt.Errorf("Server not configured to allow reading of local files")
}
name := filepath.Base(path)
in, err := ioutil.ReadFile(path)

f, err := os.Open(path)
if err != nil {
return nil, err
}
defer f.Close()

in := []byte{}
buff := [1024 * 1024]byte{}
for {
n, err := f.Read(buff[:]);
if err != nil && err != io.EOF {
return nil, err
}
in = append(in, buff[:n]...)
if err == io.EOF {
break
}
}

p, err := capture.Import(ctx, name, in)
if err != nil {
return nil, err
Expand Down

0 comments on commit 24f58fd

Please sign in to comment.