Skip to content

Commit 371b3b6

Browse files
committed
Improve freshness detection
1 parent c3cc949 commit 371b3b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/elastic-etcd/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,16 @@ func Run(args []string) (*EtcdConfig, string, error) {
226226
if dataDir == "" {
227227
dataDir = name + ".etcd"
228228
}
229-
fresh := !fileutil.Exist(dataDir)
229+
fresh := true
230+
if fileutil.Exist(dataDir) {
231+
fs, err := fileutil.ReadDir(dataDir)
232+
if err != nil {
233+
actionErr = err
234+
return
235+
}
236+
glog.V(6).Info("Found the following files in %s: %v", dataDir, fs)
237+
fresh = len(fs) <= 2
238+
}
230239

231240
jr, err := join.Join(
232241
discoveryURL,

0 commit comments

Comments
 (0)