mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
fix(DB): modify new data store checking logic (#5756)
* update new data store check logic * cleanup
This commit is contained in:
parent
af98660a55
commit
01529203f1
1 changed files with 13 additions and 7 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue