···540540 // a little weird that this is the same action as a takedown
541541 return p.deleteAllEventsForUser(ctx, usr)
542542}
543543+544544+func (p *DbPersistence) Shutdown(context.Context) error {
545545+ return nil
546546+}
+17-1
events/diskpersist.go
···4444 outbuf *bytes.Buffer
4545 evtbuf []persistJob
46464747+ shutdown chan struct{}
4848+4749 lk sync.Mutex
4850}
4951···116118 scratch: make([]byte, headerSize),
117119 outbuf: new(bytes.Buffer),
118120 writeBufferSize: opts.WriteBufferSize,
121121+ shutdown: make(chan struct{}),
119122 }
120123121124 if err := dp.resumeLog(); err != nil {
···145148 return dp.initLogFile()
146149 }
147150148148- fi, err := os.Open(filepath.Join(dp.primaryDir, lfr.Path))
151151+ // 0 for the mode is fine since thats only used if O_CREAT is passed
152152+ fi, err := os.OpenFile(filepath.Join(dp.primaryDir, lfr.Path), os.O_RDWR, 0)
149153 if err != nil {
150154 return err
151155 }
···284288285289 for {
286290 select {
291291+ case <-p.shutdown:
292292+ return
287293 case <-t.C:
288294 p.lk.Lock()
289295 if err := p.flushLog(context.TODO()); err != nil {
···705711 if len(p.evtbuf) > 0 {
706712 return p.flushLog(ctx)
707713 }
714714+ return nil
715715+}
716716+717717+func (p *DiskPersistence) Shutdown(ctx context.Context) error {
718718+ close(p.shutdown)
719719+ if err := p.Flush(ctx); err != nil {
720720+ return err
721721+ }
722722+723723+ p.logfi.Close()
708724 return nil
709725}
710726