Skip to content

Commit

Permalink
Config: Improve options report and change BackupRetain default #4243
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Mayer <michael@photoprism.app>
  • Loading branch information
lastzero committed May 13, 2024
1 parent 7805280 commit db5336a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
12 changes: 9 additions & 3 deletions internal/config/cli_flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import (
"reflect"
"strings"

"github.com/photoprism/photoprism/pkg/list"
"github.com/urfave/cli"

"github.com/photoprism/photoprism/pkg/list"
)

// CliFlag represents a command-line parameter.
type CliFlag struct {
Flag cli.DocGenerationFlag
Tags []string
Flag cli.DocGenerationFlag
Tags []string
DocDefault string
}

// Skip checks if the parameter should be skipped based on a list of tags.
Expand All @@ -32,6 +34,10 @@ func (f CliFlag) Fields() reflect.Value {

// Default returns the default value.
func (f CliFlag) Default() string {
if f.DocDefault != "" {
return f.DocDefault
}

return f.Flag.GetValue()
}

Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

const (
DefaultBackupSchedule = "0 12 * * *"
DefaultBackupRetain = 10
DefaultBackupRetain = 3
)

// BackupPath returns the backup storage path based on the specified type, or the base path if none is specified.
Expand Down
6 changes: 3 additions & 3 deletions internal/config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var Flags = CliFlags{
Name: "sidecar-yaml",
Usage: "export picture metadata to YAML sidecar files",
EnvVar: EnvVar("SIDECAR_YAML"),
}}, {
}, DocDefault: "true"}, {
Flag: cli.StringFlag{
Name: "cache-path, ca",
Usage: "custom cache `PATH` for sessions and thumbnail files *optional*",
Expand Down Expand Up @@ -207,12 +207,12 @@ var Flags = CliFlags{
Name: "backup-index",
Usage: "create index database backups based on the configured schedule",
EnvVar: EnvVar("BACKUP_INDEX"),
}}, {
}, DocDefault: "true"}, {
Flag: cli.BoolFlag{
Name: "backup-albums",
Usage: "export album metadata to YAML backup files",
EnvVar: EnvVar("BACKUP_ALBUMS"),
}}, {
}, DocDefault: "true"}, {
Flag: cli.IntFlag{
Name: "index-workers, workers",
Usage: "maximum `NUMBER` of indexing workers, default depends on the number of physical cores",
Expand Down
6 changes: 3 additions & 3 deletions internal/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type Options struct {
UsersPath string `yaml:"UsersPath" json:"-" flag:"users-path"`
StoragePath string `yaml:"StoragePath" json:"-" flag:"storage-path"`
SidecarPath string `yaml:"SidecarPath" json:"-" flag:"sidecar-path"`
SidecarYaml bool `yaml:"SidecarYaml" json:"SidecarYaml" flag:"sidecar-yaml"`
SidecarYaml bool `yaml:"SidecarYaml" json:"SidecarYaml" flag:"sidecar-yaml" default:"true"`
CachePath string `yaml:"CachePath" json:"-" flag:"cache-path"`
ImportPath string `yaml:"ImportPath" json:"-" flag:"import-path"`
ImportDest string `yaml:"ImportDest" json:"-" flag:"import-dest"`
Expand All @@ -60,8 +60,8 @@ type Options struct {
BackupPath string `yaml:"BackupPath" json:"-" flag:"backup-path"`
BackupSchedule string `yaml:"BackupSchedule" json:"BackupSchedule" flag:"backup-schedule"`
BackupRetain int `yaml:"BackupRetain" json:"BackupRetain" flag:"backup-retain"`
BackupIndex bool `yaml:"BackupIndex" json:"BackupIndex" flag:"backup-index"`
BackupAlbums bool `yaml:"BackupAlbums" json:"BackupAlbums" flag:"backup-albums"`
BackupIndex bool `yaml:"BackupIndex" json:"BackupIndex" flag:"backup-index" default:"true"`
BackupAlbums bool `yaml:"BackupAlbums" json:"BackupAlbums" flag:"backup-albums" default:"true"`
IndexWorkers int `yaml:"IndexWorkers" json:"IndexWorkers" flag:"index-workers"`
IndexSchedule string `yaml:"IndexSchedule" json:"IndexSchedule" flag:"index-schedule"`
WakeupInterval time.Duration `yaml:"WakeupInterval" json:"WakeupInterval" flag:"wakeup-interval"`
Expand Down

0 comments on commit db5336a

Please sign in to comment.