mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #12846 from pyiyun/fix-snaptmpfile-bug
etcdserver: remove temp files in snap dir when etcdserver starting
This commit is contained in:
@@ -26,6 +26,7 @@ import (
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -337,6 +338,17 @@ func NewServer(cfg config.ServerConfig) (srv *EtcdServer, err error) {
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
|
||||
if err = fileutil.RemoveMatchFile(cfg.Logger, cfg.SnapDir(), func(fileName string) bool {
|
||||
return strings.HasPrefix(fileName, "tmp")
|
||||
}); err != nil {
|
||||
cfg.Logger.Error(
|
||||
"failed to remove temp file(s) in snapshot directory",
|
||||
zap.String("path", cfg.SnapDir()),
|
||||
zap.Error(err),
|
||||
)
|
||||
}
|
||||
|
||||
ss := snap.New(cfg.Logger, cfg.SnapDir())
|
||||
|
||||
bepath := cfg.BackendPath()
|
||||
|
||||
Reference in New Issue
Block a user