wal: remove redundant war tmp dirs if create wal failed
If we create 000000000-0000000.war failed in war tmp dir(XXX.tmp) and we should
remove the tmp dirs. If create war successfully in tmp dir and it will
be renamed to common dir and remove tmp dir(XXX.tmp) will also be ok.
@@ -114,6 +114,8 @@ func Create(lg *zap.Logger, dirpath string, metadata []byte) (*WAL, error) {
return nil, err
}
}
+ defer os.RemoveAll(tmpdirpath)
+
if err := fileutil.CreateDirAll(tmpdirpath); err != nil {
lg.Warn(
"failed to create a temporary WAL directory",
