Commit b22a55a5 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Don't print warning for splicing zero length file.

parent e98b6688
......@@ -525,6 +525,19 @@ func TestFSync(t *testing.T) {
f.Close()
}
func TestReadZero(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
err := ioutil.WriteFile(ts.origFile, []byte{}, 0644)
CheckSuccess(err)
back, err := ioutil.ReadFile(ts.mountFile)
CheckSuccess(err)
if len(back) != 0 {
t.Errorf("content length: got %d want %d", len(back), 0)
}
}
func TestReadLarge(t *testing.T) {
ts := NewTestCase(t)
defer ts.Cleanup()
......
......@@ -399,7 +399,7 @@ func (ms *MountState) TrySplice(header []byte, req *request,
} else {
n, err = finalSplice.LoadFromAt(fd, size, off)
}
if err == io.EOF || (err == nil && n < size && n > 0) {
if err == io.EOF || (err == nil && n < size) {
discard := make([]byte, len(header))
_, err = finalSplice.Read(discard)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment