Browse Source

write file info only when data is not empty

pull/2/head
Chris Lu 12 years ago
parent
commit
90018be9d2
  1. 2
      go/storage/needle_read_write.go

2
go/storage/needle_read_write.go

@ -87,7 +87,6 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, err error) {
if _, err = w.Write(header[0:1]); err != nil { if _, err = w.Write(header[0:1]); err != nil {
return return
} }
}
if n.HasName() { if n.HasName() {
util.Uint8toBytes(header[0:1], n.NameSize) util.Uint8toBytes(header[0:1], n.NameSize)
if _, err = w.Write(header[0:1]); err != nil { if _, err = w.Write(header[0:1]); err != nil {
@ -112,6 +111,7 @@ func (n *Needle) Append(w io.Writer, version Version) (size uint32, err error) {
return return
} }
} }
}
padding := NeedlePaddingSize - ((NeedleHeaderSize + n.Size + NeedleChecksumSize) % NeedlePaddingSize) padding := NeedlePaddingSize - ((NeedleHeaderSize + n.Size + NeedleChecksumSize) % NeedlePaddingSize)
util.Uint32toBytes(header[0:NeedleChecksumSize], n.Checksum.Value()) util.Uint32toBytes(header[0:NeedleChecksumSize], n.Checksum.Value())
_, err = w.Write(header[0 : NeedleChecksumSize+padding]) _, err = w.Write(header[0 : NeedleChecksumSize+padding])

Loading…
Cancel
Save