wal: remove redundant war tmp dirs if create wal failed (#12388)

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.

Co-authored-by: yangweiwei <yangweiwei@cmss.chinamobile.com>
This commit is contained in:
vivian 2020-10-13 23:11:52 +08:00 committed by GitHub
parent 0b95e8cef1
commit 667ed96957
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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",