mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Convert: Pass sub folder as first argument to limit scope #1081
see https://github.com/photoprism/photoprism/discussions/1081
This commit is contained in:
@@ -2,6 +2,9 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/photoprism/photoprism/pkg/txt"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/photoprism/photoprism/internal/config"
|
"github.com/photoprism/photoprism/internal/config"
|
||||||
@@ -11,9 +14,10 @@ import (
|
|||||||
|
|
||||||
// ConvertCommand registers the convert cli command.
|
// ConvertCommand registers the convert cli command.
|
||||||
var ConvertCommand = cli.Command{
|
var ConvertCommand = cli.Command{
|
||||||
Name: "convert",
|
Name: "convert",
|
||||||
Usage: "Converts originals in other formats to JPEG and AVC sidecar files",
|
Usage: "Converts originals in other formats to JPEG and AVC sidecar files",
|
||||||
Action: convertAction,
|
UsageText: `To limit scope, a sub folder may be passed as first argument.`,
|
||||||
|
Action: convertAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
// convertAction converts originals in other formats to JPEG and AVC sidecar files.
|
// convertAction converts originals in other formats to JPEG and AVC sidecar files.
|
||||||
@@ -34,11 +38,20 @@ func convertAction(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("converting originals in %s", conf.OriginalsPath())
|
convertPath := conf.OriginalsPath()
|
||||||
|
|
||||||
|
// Use first argument to limit scope if set.
|
||||||
|
subPath := strings.TrimSpace(ctx.Args().First())
|
||||||
|
|
||||||
|
if subPath != "" {
|
||||||
|
convertPath = filepath.Join(convertPath, subPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Infof("converting originals in %s", txt.Quote(convertPath))
|
||||||
|
|
||||||
convert := service.Convert()
|
convert := service.Convert()
|
||||||
|
|
||||||
if err := convert.Start(conf.OriginalsPath()); err != nil {
|
if err := convert.Start(convertPath); err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,11 @@ import (
|
|||||||
|
|
||||||
// IndexCommand registers the index cli command.
|
// IndexCommand registers the index cli command.
|
||||||
var IndexCommand = cli.Command{
|
var IndexCommand = cli.Command{
|
||||||
Name: "index",
|
Name: "index",
|
||||||
Usage: "Indexes media files in originals folder",
|
Usage: "Indexes media files in originals folder",
|
||||||
Flags: indexFlags,
|
UsageText: `To limit scope, a sub folder may be passed as first argument.`,
|
||||||
Action: indexAction,
|
Flags: indexFlags,
|
||||||
|
Action: indexAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
var indexFlags = []cli.Flag{
|
var indexFlags = []cli.Flag{
|
||||||
@@ -48,13 +49,13 @@ func indexAction(ctx *cli.Context) error {
|
|||||||
|
|
||||||
conf.InitDb()
|
conf.InitDb()
|
||||||
|
|
||||||
// get cli first argument
|
// Use first argument to limit scope if set.
|
||||||
subPath := strings.TrimSpace(ctx.Args().First())
|
subPath := strings.TrimSpace(ctx.Args().First())
|
||||||
|
|
||||||
if subPath == "" {
|
if subPath == "" {
|
||||||
log.Infof("indexing photos in %s", txt.Quote(conf.OriginalsPath()))
|
log.Infof("indexing originals in %s", txt.Quote(conf.OriginalsPath()))
|
||||||
} else {
|
} else {
|
||||||
log.Infof("indexing originals folder %s", txt.Quote(filepath.Join(conf.OriginalsPath(), subPath)))
|
log.Infof("indexing originals in %s", txt.Quote(filepath.Join(conf.OriginalsPath(), subPath)))
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.ReadOnly() {
|
if conf.ReadOnly() {
|
||||||
|
|||||||
Reference in New Issue
Block a user