Fix initial setup issue issues (#1380)

* Refactor initial setup behaviour
* Adjust wizard
This commit is contained in:
WithoutPants
2021-05-13 22:15:21 +10:00
committed by GitHub
parent 5a37e6cf52
commit e0623eb302
6 changed files with 133 additions and 34 deletions

View File

@@ -49,6 +49,11 @@ func Initialize() *singleton {
once.Do(func() {
_ = utils.EnsureDir(paths.GetStashHomeDirectory())
cfg, err := config.Initialize()
if err != nil {
panic(fmt.Sprintf("error initializing configuration: %s", err.Error()))
}
initLog()
instance = &singleton{
@@ -59,8 +64,7 @@ func Initialize() *singleton {
TxnManager: sqlite.NewTransactionManager(),
}
cfgFile := cfg.GetConfigFile()
if cfgFile != "" {
if !cfg.IsNewSystem() {
logger.Infof("using config file: %s", cfg.GetConfigFile())
if err == nil {
@@ -75,7 +79,11 @@ func Initialize() *singleton {
}
}
} else {
logger.Warn("config file not found. Assuming new system...")
cfgFile := cfg.GetConfigFile()
if cfgFile != "" {
cfgFile = cfgFile + " "
}
logger.Warnf("config file %snot found. Assuming new system...", cfgFile)
}
initFFMPEG()
@@ -235,6 +243,8 @@ func (s *singleton) Setup(input models.SetupInput) error {
return fmt.Errorf("error initializing the database: %s", err.Error())
}
s.Config.FinalizeSetup()
return nil
}
@@ -283,8 +293,9 @@ func (s *singleton) GetSystemStatus() *models.SystemStatus {
dbSchema := int(database.Version())
dbPath := database.DatabasePath()
appSchema := int(database.AppSchemaVersion())
configFile := s.Config.GetConfigFile()
if s.Config.GetConfigFile() == "" {
if s.Config.IsNewSystem() {
status = models.SystemStatusEnumSetup
} else if dbSchema < appSchema {
status = models.SystemStatusEnumNeedsMigration
@@ -295,5 +306,6 @@ func (s *singleton) GetSystemStatus() *models.SystemStatus {
DatabasePath: &dbPath,
AppSchema: appSchema,
Status: status,
ConfigPath: &configFile,
}
}