Browse Source

Issue 26: Could not download uploaded files

Fix is provided by hieu.hcmus, He convinced me of the fix. Thanks!
pull/2/head
Chris Lu 12 years ago
parent
commit
e30e325770
  1. 10
      go/storage/volume.go

10
go/storage/volume.go

@ -169,6 +169,15 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
if offset, err = v.dataFile.Seek(0, 2); err != nil {
return
}
//ensure file writing starting from aligned positions
if offset%NeedlePaddingSize != 0 {
offset = offset + (NeedlePaddingSize - offset%NeedlePaddingSize)
if offset, err = v.dataFile.Seek(offset, 0); err != nil {
return
}
}
if size, err = n.Append(v.dataFile, v.Version()); err != nil {
if e := v.dataFile.Truncate(offset); e != nil {
err = fmt.Errorf("%s\ncannot truncate %s: %s", err, v.dataFile, e)
@ -181,6 +190,7 @@ func (v *Volume) write(n *Needle) (size uint32, err error) {
}
return
}
func (v *Volume) delete(n *Needle) (uint32, error) {
if v.readOnly {
return 0, fmt.Errorf("%s is read-only", v.dataFile)

Loading…
Cancel
Save