mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Issue 26: Could not download uploaded files
Fix is provided by hieu.hcmus, He convinced me of the fix. Thanks!
This commit is contained in:
parent
d1fcf1fd67
commit
e30e325770
|
@ -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…
Reference in a new issue