mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
close tempfiles, fix path print
This commit is contained in:
@@ -235,6 +235,7 @@ func newFileStoreWithCreated(fcfg FileStoreConfig, cfg StreamConfig, created tim
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("storage directory is not writable")
|
||||
}
|
||||
tmpfile.Close()
|
||||
os.Remove(tmpfile.Name())
|
||||
|
||||
fs := &fileStore{
|
||||
@@ -3192,7 +3193,12 @@ func (mb *msgBlock) close(sync bool) {
|
||||
if sync {
|
||||
syncAndClose(mb.mfd, mb.ifd)
|
||||
} else {
|
||||
go syncAndClose(mb.mfd, mb.ifd)
|
||||
if mb.mfd != nil {
|
||||
mb.mfd.Close()
|
||||
}
|
||||
if mb.ifd != nil {
|
||||
mb.ifd.Close()
|
||||
}
|
||||
}
|
||||
mb.mfd = nil
|
||||
mb.ifd = nil
|
||||
@@ -3209,6 +3215,14 @@ func (fs *fileStore) Delete() error {
|
||||
return ErrStoreClosed
|
||||
}
|
||||
fs.Purge()
|
||||
|
||||
pdir := path.Join(fs.fcfg.StoreDir, purgeDir)
|
||||
// If purge directory still exists then we need to wait
|
||||
// in place and remove since rename would fail.
|
||||
if _, err := os.Stat(pdir); err == nil {
|
||||
os.RemoveAll(pdir)
|
||||
}
|
||||
|
||||
if err := fs.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ func (s *Server) enableJetStream(cfg JetStreamConfig) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("storage directory is not writable")
|
||||
}
|
||||
tmpfile.Close()
|
||||
os.Remove(tmpfile.Name())
|
||||
}
|
||||
|
||||
@@ -199,7 +200,7 @@ func (s *Server) enableJetStream(cfg JetStreamConfig) error {
|
||||
s.Noticef("---------------- JETSTREAM ----------------")
|
||||
s.Noticef(" Max Memory: %s", friendlyBytes(cfg.MaxMemory))
|
||||
s.Noticef(" Max Storage: %s", friendlyBytes(cfg.MaxStore))
|
||||
s.Noticef(" Store Directory: %q", cfg.StoreDir)
|
||||
s.Noticef(" Store Directory: \"%s\"", cfg.StoreDir)
|
||||
s.Noticef("-------------------------------------------")
|
||||
|
||||
// Setup our internal subscriptions.
|
||||
|
||||
@@ -309,6 +309,7 @@ func (s *Server) bootstrapRaftNode(cfg *RaftConfig, knownPeers []string, allPeer
|
||||
if err != nil {
|
||||
return fmt.Errorf("raft: storage directory is not writable")
|
||||
}
|
||||
tmpfile.Close()
|
||||
os.Remove(tmpfile.Name())
|
||||
|
||||
return writePeerState(cfg.Store, &peerState{knownPeers, expected})
|
||||
|
||||
Reference in New Issue
Block a user