Explorar el Código

raftsnap: clarify "ErrNoDBSnapshot"

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
Gyuho Lee hace 8 años
padre
commit
e2af59e4d1
Se han modificado 1 ficheros con 10 adiciones y 1 borrados
  1. 10 1
      raftsnap/db.go

+ 10 - 1
raftsnap/db.go

@@ -76,9 +76,18 @@ func (s *Snapshotter) DBFilePath(id uint64) (string, error) {
 	if _, err := fileutil.ReadDir(s.dir); err != nil {
 		return "", err
 	}
-	if fn := s.dbFilePath(id); fileutil.Exist(fn) {
+	fn := s.dbFilePath(id)
+	if fileutil.Exist(fn) {
 		return fn, nil
 	}
+	if s.lg != nil {
+		s.lg.Warn(
+			"failed to find [SNAPSHOT-INDEX].snap.db",
+			zap.Uint64("snapshot-index", id),
+			zap.String("snapshot-file-path", fn),
+			zap.Error(ErrNoDBSnapshot),
+		)
+	}
 	return "", ErrNoDBSnapshot
 }