CLI: Refactor tests and config initialization

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2022-10-04 12:27:40 +02:00
parent e2b315d79d
commit c7be7c43eb
22 changed files with 85 additions and 84 deletions

View File

@@ -34,21 +34,20 @@ var CopyCommand = cli.Command{
func copyAction(ctx *cli.Context) error {
start := time.Now()
conf := config.NewConfig(ctx)
service.SetConfig(conf)
// very if copy directory exist and is writable
if conf.ReadOnly() {
return config.ErrReadOnly
}
conf, err := InitConfig(ctx)
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(); err != nil {
if err != nil {
return err
}
// very if copy directory exist and is writable
if conf.ReadOnly() {
return config.ErrReadOnly
}
conf.InitDb()
defer conf.Shutdown()