Rename Config.GetOriginalsPath() to OriginalsPath(), see #50

This commit is contained in:
Michael Mayer 2018-12-21 03:21:21 +01:00
parent b365a2ce57
commit c1219799da
17 changed files with 38 additions and 37 deletions

View file

@ -29,7 +29,7 @@ func GetPhotos(router *gin.RouterGroup, conf photoprism.Config) {
router.GET("/photos", func(c *gin.Context) {
var form forms.PhotoSearchForm
search := photoprism.NewSearch(conf.GetOriginalsPath(), conf.Db())
search := photoprism.NewSearch(conf.OriginalsPath(), conf.Db())
c.MustBindWith(&form, binding.Form)
@ -52,7 +52,7 @@ func GetPhotos(router *gin.RouterGroup, conf photoprism.Config) {
// photoId: int Photo ID as returned by the API
func LikePhoto(router *gin.RouterGroup, conf photoprism.Config) {
router.POST("/photos/:photoId/like", func(c *gin.Context) {
search := photoprism.NewSearch(conf.GetOriginalsPath(), conf.Db())
search := photoprism.NewSearch(conf.OriginalsPath(), conf.Db())
photoId, err := strconv.ParseUint(c.Param("photoId"), 10, 64)
@ -74,7 +74,7 @@ func LikePhoto(router *gin.RouterGroup, conf photoprism.Config) {
// photoId: int Photo ID as returned by the API
func DislikePhoto(router *gin.RouterGroup, conf photoprism.Config) {
router.DELETE("/photos/:photoId/like", func(c *gin.Context) {
search := photoprism.NewSearch(conf.GetOriginalsPath(), conf.Db())
search := photoprism.NewSearch(conf.OriginalsPath(), conf.Db())
photoId, err := strconv.ParseUint(c.Param("photoId"), 10, 64)

View file

@ -32,11 +32,11 @@ func GetThumbnail(router *gin.RouterGroup, conf photoprism.Config) {
c.Data(400, "image/svg+xml", photoIconSvg)
}
search := photoprism.NewSearch(conf.GetOriginalsPath(), conf.Db())
search := photoprism.NewSearch(conf.OriginalsPath(), conf.Db())
file := search.FindFileByHash(fileHash)
fileName := fmt.Sprintf("%s/%s", conf.GetOriginalsPath(), file.FileName)
fileName := fmt.Sprintf("%s/%s", conf.OriginalsPath(), file.FileName)
if mediaFile, err := photoprism.NewMediaFile(fileName); err == nil {
switch thumbnailType {

View file

@ -21,7 +21,7 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("debug %t\n", conf.Debug())
fmt.Printf("config-file %s\n", conf.ConfigFile())
fmt.Printf("darktable-cli %s\n", conf.GetDarktableCli())
fmt.Printf("originals-path %s\n", conf.GetOriginalsPath())
fmt.Printf("originals-path %s\n", conf.OriginalsPath())
fmt.Printf("import-path %s\n", conf.GetImportPath())
fmt.Printf("export-path %s\n", conf.GetExportPath())
fmt.Printf("cache-path %s\n", conf.GetCachePath())

View file

@ -23,11 +23,11 @@ func convertAction(ctx *cli.Context) error {
log.Fatal(err)
}
fmt.Printf("Converting RAW images in %s to JPEG...\n", conf.GetOriginalsPath())
fmt.Printf("Converting RAW images in %s to JPEG...\n", conf.OriginalsPath())
converter := photoprism.NewConverter(conf.GetDarktableCli())
converter.ConvertAll(conf.GetOriginalsPath())
converter.ConvertAll(conf.OriginalsPath())
fmt.Println("Done.")

View file

@ -71,7 +71,7 @@ func exportAction(ctx *cli.Context) error {
exportPath := fmt.Sprintf("%s/%s", conf.GetExportPath(), name)
size := ctx.Int("size")
originals := photoprism.FindOriginalsByDate(conf.GetOriginalsPath(), afterDate, beforeDate)
originals := photoprism.FindOriginalsByDate(conf.OriginalsPath(), afterDate, beforeDate)
fmt.Printf("Exporting photos to %s...\n", exportPath)

View file

@ -29,11 +29,11 @@ func importAction(ctx *cli.Context) error {
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := photoprism.NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := photoprism.NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
converter := photoprism.NewConverter(conf.GetDarktableCli())
importer := photoprism.NewImporter(conf.GetOriginalsPath(), indexer, converter)
importer := photoprism.NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())

View file

@ -25,11 +25,11 @@ func indexAction(ctx *cli.Context) error {
conf.MigrateDb()
fmt.Printf("Indexing photos in %s...\n", conf.GetOriginalsPath())
fmt.Printf("Indexing photos in %s...\n", conf.OriginalsPath())
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := photoprism.NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := photoprism.NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
indexer.IndexAll()

View file

@ -51,7 +51,7 @@ func thumbnailsAction(ctx *cli.Context) error {
}
for _, size := range sizes {
photoprism.CreateThumbnailsFromOriginals(conf.GetOriginalsPath(), conf.GetThumbnailsPath(), size, ctx.Bool("square"))
photoprism.CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.GetThumbnailsPath(), size, ctx.Bool("square"))
}
fmt.Println("Done.")

View file

@ -213,7 +213,7 @@ func (c *Config) SetValuesFromCliContext(ctx *cli.Context) error {
// importPath
// exportPath
func (c *Config) CreateDirectories() error {
if err := os.MkdirAll(c.GetOriginalsPath(), os.ModePerm); err != nil {
if err := os.MkdirAll(c.OriginalsPath(), os.ModePerm); err != nil {
return err
}
@ -346,8 +346,8 @@ func (c *Config) HttpServerMode() string {
return c.serverMode
}
// GetOriginalsPath returns the originals.
func (c *Config) GetOriginalsPath() string {
// OriginalsPath returns the originals.
func (c *Config) OriginalsPath() string {
return c.originalsPath
}

View file

@ -31,7 +31,7 @@ func TestConfig_SetValuesFromFile(t *testing.T) {
assert.Equal(t, "/srv/photoprism", c.GetAssetsPath())
assert.Equal(t, "/srv/photoprism/cache", c.GetCachePath())
assert.Equal(t, "/srv/photoprism/cache/thumbnails", c.GetThumbnailsPath())
assert.Equal(t, "/srv/photoprism/photos/originals", c.GetOriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/originals", c.OriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath())
assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath())
assert.Equal(t, "tidb", c.DatabaseDriver())

View file

@ -31,7 +31,8 @@ type Config interface {
DatabaseDriver() string
DatabaseDsn() string
GetOriginalsPath() string
OriginalsPath() string
GetImportPath() string
GetExportPath() string
GetDarktableCli() string

View file

@ -55,7 +55,7 @@ func TestContextConfig_SetValuesFromFile(t *testing.T) {
assert.Equal(t, "/srv/photoprism", c.GetAssetsPath())
assert.Equal(t, "/srv/photoprism/cache", c.GetCachePath())
assert.Equal(t, "/srv/photoprism/cache/thumbnails", c.GetThumbnailsPath())
assert.Equal(t, "/srv/photoprism/photos/originals", c.GetOriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/originals", c.OriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath())
assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath())
assert.Equal(t, "tidb", c.DatabaseDriver())

View file

@ -15,11 +15,11 @@ func TestImporter_ImportPhotosFromDirectory(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
converter := NewConverter(conf.GetDarktableCli())
importer := NewImporter(conf.GetOriginalsPath(), indexer, converter)
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())
}

View file

@ -12,11 +12,11 @@ func TestNewImporter(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
converter := NewConverter(conf.GetDarktableCli())
importer := NewImporter(conf.GetOriginalsPath(), indexer, converter)
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
assert.IsType(t, &Importer{}, importer)
}
@ -27,11 +27,11 @@ func TestImporter_GetDestinationFilename(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
converter := NewConverter(conf.GetDarktableCli())
importer := NewImporter(conf.GetOriginalsPath(), indexer, converter)
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
rawFile, err := NewMediaFile(conf.GetImportPath() + "/raw/IMG_1435.CR2")
@ -41,5 +41,5 @@ func TestImporter_GetDestinationFilename(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, conf.GetOriginalsPath()+"/2018/02/20180204_170813_863A6248DCCA.cr2", filename)
assert.Equal(t, conf.OriginalsPath()+"/2018/02/20180204_170813_863A6248DCCA.cr2", filename)
}

View file

@ -14,7 +14,7 @@ func TestSearch_Photos_Query(t *testing.T) {
conf.InitializeTestData(t)
search := NewSearch(conf.GetOriginalsPath(), conf.Db())
search := NewSearch(conf.OriginalsPath(), conf.Db())
var form forms.PhotoSearchForm
@ -47,7 +47,7 @@ func TestSearch_Photos_Camera(t *testing.T) {
conf.InitializeTestData(t)
search := NewSearch(conf.GetOriginalsPath(), conf.Db())
search := NewSearch(conf.OriginalsPath(), conf.Db())
var form forms.PhotoSearchForm

View file

@ -17,15 +17,15 @@ func TestCreateThumbnailsFromOriginals(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
indexer := NewIndexer(conf.GetOriginalsPath(), tensorFlow, conf.Db())
indexer := NewIndexer(conf.OriginalsPath(), tensorFlow, conf.Db())
converter := NewConverter(conf.GetDarktableCli())
importer := NewImporter(conf.GetOriginalsPath(), indexer, converter)
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())
CreateThumbnailsFromOriginals(conf.GetOriginalsPath(), conf.GetThumbnailsPath(), 600, false)
CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.GetThumbnailsPath(), 600, false)
CreateThumbnailsFromOriginals(conf.GetOriginalsPath(), conf.GetThumbnailsPath(), 300, true)
CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.GetThumbnailsPath(), 300, true)
}

View file

@ -44,7 +44,7 @@ type Config struct {
func (c *Config) RemoveTestData(t *testing.T) {
os.RemoveAll(c.GetImportPath())
os.RemoveAll(c.GetExportPath())
os.RemoveAll(c.GetOriginalsPath())
os.RemoveAll(c.OriginalsPath())
os.RemoveAll(c.GetCachePath())
}
@ -93,7 +93,7 @@ func NewConfig() *Config {
// ImportPath
// ExportPath
func (c *Config) CreateDirectories() error {
if err := os.MkdirAll(c.GetOriginalsPath(), os.ModePerm); err != nil {
if err := os.MkdirAll(c.OriginalsPath(), os.ModePerm); err != nil {
return err
}
@ -203,8 +203,8 @@ func (c *Config) HttpServerMode() string {
return "test"
}
// GetOriginalsPath returns the originals.
func (c *Config) GetOriginalsPath() string {
// OriginalsPath returns the originals.
func (c *Config) OriginalsPath() string {
return OriginalsPath
}