CLI: Add cluster operations and management commands #98

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-09-16 18:09:09 +02:00
parent 5db044284b
commit dbf1650c1c
24 changed files with 1862 additions and 48 deletions

View File

@@ -54,7 +54,7 @@ func resetAction(ctx *cli.Context) error {
defer conf.Shutdown()
if !ctx.Bool("yes") {
if !RunNonInteractively(ctx.Bool("yes")) {
log.Warnf("This will delete and recreate your index database after confirmation")
if !ctx.Bool("index") {
@@ -67,7 +67,7 @@ func resetAction(ctx *cli.Context) error {
log.Infoln("reset: enabled trace mode")
}
confirmed := ctx.Bool("yes")
confirmed := RunNonInteractively(ctx.Bool("yes"))
// Show prompt?
if !confirmed {
@@ -94,48 +94,55 @@ func resetAction(ctx *cli.Context) error {
}
// Clear cache.
removeCachePrompt := promptui.Prompt{
Label: "Clear cache incl thumbnails?",
IsConfirm: true,
}
if _, err = removeCachePrompt.Run(); err == nil {
resetCache(conf)
} else {
if RunNonInteractively(false) {
log.Infof("keeping cache files")
} else {
removeCachePrompt := promptui.Prompt{Label: "Clear cache incl thumbnails?", IsConfirm: true}
if _, err = removeCachePrompt.Run(); err == nil {
resetCache(conf)
} else {
log.Infof("keeping cache files")
}
}
// *.json sidecar files.
removeSidecarJsonPrompt := promptui.Prompt{
Label: "Delete all *.json sidecar files?",
IsConfirm: true,
}
if _, err = removeSidecarJsonPrompt.Run(); err == nil {
resetSidecarJson(conf)
} else {
if RunNonInteractively(false) {
log.Infof("keeping *.json sidecar files")
} else {
removeSidecarJsonPrompt := promptui.Prompt{Label: "Delete all *.json sidecar files?", IsConfirm: true}
if _, err = removeSidecarJsonPrompt.Run(); err == nil {
resetSidecarJson(conf)
} else {
log.Infof("keeping *.json sidecar files")
}
}
// *.yml metadata files.
removeSidecarYamlPrompt := promptui.Prompt{
Label: "Delete all *.yml metadata files?",
IsConfirm: true,
}
if _, err = removeSidecarYamlPrompt.Run(); err == nil {
resetSidecarYaml(conf)
} else {
if RunNonInteractively(false) {
log.Infof("keeping *.yml metadata files")
} else {
removeSidecarYamlPrompt := promptui.Prompt{Label: "Delete all *.yml metadata files?", IsConfirm: true}
if _, err = removeSidecarYamlPrompt.Run(); err == nil {
resetSidecarYaml(conf)
} else {
log.Infof("keeping *.yml metadata files")
}
}
// *.yml album files.
removeAlbumYamlPrompt := promptui.Prompt{
Label: "Delete all *.yml album files?",
IsConfirm: true,
if !RunNonInteractively(false) {
removeAlbumYamlPrompt := promptui.Prompt{Label: "Delete all *.yml album files?", IsConfirm: true}
if _, err = removeAlbumYamlPrompt.Run(); err != nil {
log.Infof("keeping *.yml album files")
return nil
}
} else {
log.Infof("keeping *.yml album files")
return nil
}
if _, err = removeAlbumYamlPrompt.Run(); err == nil {
// If confirmed, proceed to delete album YAML files
{
start := time.Now()
matches, globErr := filepath.Glob(regexp.QuoteMeta(conf.BackupAlbumsPath()) + "/**/*.yml")
@@ -161,8 +168,6 @@ func resetAction(ctx *cli.Context) error {
} else {
log.Infof("found no *.yml album files")
}
} else {
log.Infof("keeping *.yml album files")
}
return nil