mirror of https://github.com/portainer/portainer
fix(DB): modify new data store checking logic (#5756)
* update new data store check logic * cleanuppull/5790/head
parent
af98660a55
commit
01529203f1
|
@ -99,15 +99,10 @@ func NewStore(storePath string, fileService portainer.FileService) (*Store, erro
|
|||
}
|
||||
|
||||
databasePath := path.Join(storePath, databaseFileName)
|
||||
databaseFileExists, err := fileService.FileExists(databasePath)
|
||||
if err != nil {
|
||||
if _, err := fileService.FileExists(databasePath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if databaseFileExists {
|
||||
store.isNew = false
|
||||
}
|
||||
|
||||
return store, nil
|
||||
}
|
||||
|
||||
|
@ -120,7 +115,18 @@ func (store *Store) Open() error {
|
|||
}
|
||||
store.connection.DB = db
|
||||
|
||||
return store.initServices()
|
||||
err = store.initServices()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//if failed to retrieve DBVersion from database
|
||||
//treat it as a new store
|
||||
if _, err := store.VersionService.DBVersion(); err != nil {
|
||||
store.isNew = true
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close closes the BoltDB database.
|
||||
|
|
Loading…
Reference in New Issue