X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=store%2Fstore.go;fp=store%2Fstore.go;h=b05c79ed9dcbaa7f8699b2e7a302a69883cc8037;hb=59a3cf3ee57735430af09be01402bf11561b2167;hp=2595f88213f479a80873d63fa3c5957f74826d33;hpb=c89b19c863fc41c0312358a866aebd425f498c76;p=epoint diff --git a/store/store.go b/store/store.go index 2595f88..b05c79e 100644 --- a/store/store.go +++ b/store/store.go @@ -41,8 +41,7 @@ func (c *Conn) Ensure(name string) (err error) { func (c *Conn) Set(name, k string, v []byte) (err error) { fn := filepath.Join(c.path, name, k) - // os.O_SYNC - f, err := os.Create(fn+".tmp") + f, err := os.OpenFile(fn+".tmp", os.O_CREATE|os.O_TRUNC|os.O_WRONLY|os.O_SYNC, 0666) if err != nil { return } @@ -55,6 +54,17 @@ func (c *Conn) Set(name, k string, v []byte) (err error) { return } +func (c *Conn) Append(name, k string, v []byte) (err error) { + fn := filepath.Join(c.path, name, k) + f, err := os.OpenFile(fn, os.O_CREATE|os.O_APPEND|os.O_WRONLY|os.O_SYNC, 0666) + if err != nil { + return + } + defer f.Close() + _, err = f.Write(v) + return +} + func (c *Conn) Close() (err error) { return }