photoprism/internal/commands/index.go

40 lines
792 B
Go
Raw Normal View History

package commands
import (
"fmt"
"log"
"github.com/photoprism/photoprism/internal/context"
"github.com/photoprism/photoprism/internal/photoprism"
"github.com/urfave/cli"
)
var IndexCommand = cli.Command{
Name: "index",
Usage: "Re-indexes all originals",
Action: indexAction,
}
// Indexes original photos; called by IndexCommand
func indexAction(ctx *cli.Context) error {
conf := context.NewConfig(ctx)
if err := conf.CreateDirectories(); err != nil {
log.Fatal(err)
}
conf.MigrateDb()
fmt.Printf("Indexing photos in %s...\n", conf.GetOriginalsPath())
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := photoprism.NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.GetDb())
indexer.IndexAll()
fmt.Println("Done.")
return nil
}