Skip to content

Commit

Permalink
Merge branch 'master' into skip-fs-cache-based-on-config
Browse files Browse the repository at this point in the history
  • Loading branch information
peczenyj authored Nov 5, 2023
2 parents b9090f8 + deda595 commit 6c2401b
Show file tree
Hide file tree
Showing 4 changed files with 849 additions and 49 deletions.
8 changes: 8 additions & 0 deletions client_timing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ type fakeClientConn struct {
ch chan struct{}
}

func (c *fakeClientConn) SetWriteDeadline(t time.Time) error {
return nil
}

func (c *fakeClientConn) SetReadDeadline(t time.Time) error {
return nil
}

func (c *fakeClientConn) Write(b []byte) (int, error) {
c.ch <- struct{}{}
return len(b), nil
Expand Down
10 changes: 7 additions & 3 deletions compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"fmt"
"io"
"os"
"io/fs"
"sync"

"github.com/klauspost/compress/flate"
Expand Down Expand Up @@ -421,7 +421,7 @@ func newCompressWriterPoolMap() []*sync.Pool {
return m
}

func isFileCompressible(f *os.File, minCompressRatio float64) bool {
func isFileCompressible(f fs.File, minCompressRatio float64) bool {
// Try compressing the first 4kb of the file
// and see if it can be compressed by more than
// the given minCompressRatio.
Expand All @@ -433,7 +433,11 @@ func isFileCompressible(f *os.File, minCompressRatio float64) bool {
}
_, err := copyZeroAlloc(zw, lr)
releaseStacklessGzipWriter(zw, CompressDefaultCompression)
f.Seek(0, 0) //nolint:errcheck
seeker, ok := f.(io.Seeker)
if !ok {
return false
}
seeker.Seek(0, io.SeekStart) //nolint:errcheck
if err != nil {
return false
}
Expand Down
Loading

0 comments on commit 6c2401b

Please sign in to comment.