accurate error messages during writing

This commit is contained in:
Chris Lu 2013-04-14 19:34:37 -07:00
parent a4369b35a7
commit 95dc977608

View file

@ -174,16 +174,21 @@ func (s *Store) Close() {
} }
func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) { func (s *Store) Write(i VolumeId, n *Needle) (size uint32, err error) {
if v := s.volumes[i]; v != nil && !v.readOnly { if v := s.volumes[i]; v != nil && !v.readOnly {
size, err = v.write(n) if v.readOnly {
if err != nil && s.volumeSizeLimit < v.ContentSize()+uint64(size) && s.volumeSizeLimit >= v.ContentSize() { err = errors.New("Volume " + i + " is read only!")
log.Println("volume", i, "size is", v.ContentSize(), "close to", s.volumeSizeLimit) } else {
if err = s.Join(); err != nil { size, err = v.write(n)
log.Printf("error with Join: %s", err) if err != nil && s.volumeSizeLimit < v.ContentSize()+uint64(size) && s.volumeSizeLimit >= v.ContentSize() {
log.Println("volume", i, "size is", v.ContentSize(), "close to", s.volumeSizeLimit)
if err = s.Join(); err != nil {
log.Printf("error with Join: %s", err)
}
} }
} }
return return
} }
log.Println("volume", i, "not found!") log.Println("volume", i, "not found!")
err = errors.New("Volume " + i + " not found!")
return return
} }
func (s *Store) Delete(i VolumeId, n *Needle) (uint32, error) { func (s *Store) Delete(i VolumeId, n *Needle) (uint32, error) {