Skip to content

Commit

Permalink
remove unnecessary fs utils
Browse files Browse the repository at this point in the history
this fixes mishandling of io.EOF in the hand-rolled buffering,
which this commit replaces with a call to ioutil.ReadAll
  • Loading branch information
tstearns committed Sep 8, 2016
1 parent 752ef64 commit 221bff2
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions internals_fsutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,6 @@ func getOpenFilesByDirectoryAsync(
return nil
}

func copyFile(sf *os.File, dst string) (int64, error) {
df, err := os.Create(dst)
if err != nil {
return 0, err
}
defer df.Close()
return io.Copy(df, sf)
}

// fileExists return flag whether a given file exists
// and operation error if an unclassified failure occurs.
func fileExists(path string) (bool, error) {
Expand Down Expand Up @@ -502,21 +493,9 @@ func unGzip(filename string) ([]byte, error) {
if err != nil {
return nil, err
}
defer reader.Close()

content := new(bytes.Buffer)
byteBuffer := make([]byte, 1000)
byteRead := 0
for {
byteRead, err = reader.Read(byteBuffer)
if err == io.EOF {
break
}
content.Write(byteBuffer[0:byteRead])

}
reader.Close()
return content.Bytes(), nil

return ioutil.ReadAll(reader)
}

func isTar(data []byte) bool {
Expand Down

0 comments on commit 221bff2

Please sign in to comment.