From c1219799da96c4277f257800b76aa0d29e12ea8e Mon Sep 17 00:00:00 2001
From: Michael Mayer <michael@liquidbytes.net>
Date: Fri, 21 Dec 2018 03:21:21 +0100
Subject: [PATCH] Rename Config.GetOriginalsPath() to OriginalsPath(), see #50

---
 internal/api/photos.go                      |  6 +++---
 internal/api/thumbnails.go                  |  4 ++--
 internal/commands/config.go                 |  2 +-
 internal/commands/convert.go                |  4 ++--
 internal/commands/export.go                 |  2 +-
 internal/commands/import.go                 |  4 ++--
 internal/commands/index.go                  |  4 ++--
 internal/commands/thumbnails.go             |  2 +-
 internal/context/config.go                  |  6 +++---
 internal/context/config_test.go             |  2 +-
 internal/photoprism/config.go               |  3 ++-
 internal/photoprism/config_test.go          |  2 +-
 internal/photoprism/importer_slow_test.go   |  4 ++--
 internal/photoprism/importer_test.go        | 10 +++++-----
 internal/photoprism/search_test.go          |  4 ++--
 internal/photoprism/thumbnails_slow_test.go |  8 ++++----
 internal/test/config.go                     |  8 ++++----
 17 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/internal/api/photos.go b/internal/api/photos.go
index ddfbdcc42..9a6db5fd8 100644
--- a/internal/api/photos.go
+++ b/internal/api/photos.go
@@ -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)
 
diff --git a/internal/api/thumbnails.go b/internal/api/thumbnails.go
index cdf01f2c3..f8f8ca838 100644
--- a/internal/api/thumbnails.go
+++ b/internal/api/thumbnails.go
@@ -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 {
diff --git a/internal/commands/config.go b/internal/commands/config.go
index 8af82d4cd..15ee12e19 100644
--- a/internal/commands/config.go
+++ b/internal/commands/config.go
@@ -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())
diff --git a/internal/commands/convert.go b/internal/commands/convert.go
index 64dd29c78..9e3364f18 100644
--- a/internal/commands/convert.go
+++ b/internal/commands/convert.go
@@ -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.")
 
diff --git a/internal/commands/export.go b/internal/commands/export.go
index e53e2ffd5..21cb1c666 100644
--- a/internal/commands/export.go
+++ b/internal/commands/export.go
@@ -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)
 
diff --git a/internal/commands/import.go b/internal/commands/import.go
index 58eba5464..1aba074ed 100644
--- a/internal/commands/import.go
+++ b/internal/commands/import.go
@@ -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())
 
diff --git a/internal/commands/index.go b/internal/commands/index.go
index 84939ebcf..4d09dddcb 100644
--- a/internal/commands/index.go
+++ b/internal/commands/index.go
@@ -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()
 
diff --git a/internal/commands/thumbnails.go b/internal/commands/thumbnails.go
index 6c6930045..25408624a 100644
--- a/internal/commands/thumbnails.go
+++ b/internal/commands/thumbnails.go
@@ -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.")
diff --git a/internal/context/config.go b/internal/context/config.go
index e300c52a9..7b6b0cd6d 100644
--- a/internal/context/config.go
+++ b/internal/context/config.go
@@ -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
 }
 
diff --git a/internal/context/config_test.go b/internal/context/config_test.go
index 8bcd21255..94556ff1b 100644
--- a/internal/context/config_test.go
+++ b/internal/context/config_test.go
@@ -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())
diff --git a/internal/photoprism/config.go b/internal/photoprism/config.go
index ca2f380dc..5a08d5208 100644
--- a/internal/photoprism/config.go
+++ b/internal/photoprism/config.go
@@ -31,7 +31,8 @@ type Config interface {
 
 	DatabaseDriver() string
 	DatabaseDsn() string
-	GetOriginalsPath() string
+
+	OriginalsPath() string
 	GetImportPath() string
 	GetExportPath() string
 	GetDarktableCli() string
diff --git a/internal/photoprism/config_test.go b/internal/photoprism/config_test.go
index 0109edbad..429706c97 100644
--- a/internal/photoprism/config_test.go
+++ b/internal/photoprism/config_test.go
@@ -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())
diff --git a/internal/photoprism/importer_slow_test.go b/internal/photoprism/importer_slow_test.go
index 18d18518c..d19902ef1 100644
--- a/internal/photoprism/importer_slow_test.go
+++ b/internal/photoprism/importer_slow_test.go
@@ -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())
 }
diff --git a/internal/photoprism/importer_test.go b/internal/photoprism/importer_test.go
index 3efa63de7..b8b34e7b0 100644
--- a/internal/photoprism/importer_test.go
+++ b/internal/photoprism/importer_test.go
@@ -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)
 }
diff --git a/internal/photoprism/search_test.go b/internal/photoprism/search_test.go
index 037510782..741666a8b 100644
--- a/internal/photoprism/search_test.go
+++ b/internal/photoprism/search_test.go
@@ -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
 
diff --git a/internal/photoprism/thumbnails_slow_test.go b/internal/photoprism/thumbnails_slow_test.go
index 002e2f199..ada5d0fbd 100644
--- a/internal/photoprism/thumbnails_slow_test.go
+++ b/internal/photoprism/thumbnails_slow_test.go
@@ -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)
 }
diff --git a/internal/test/config.go b/internal/test/config.go
index bde356f3e..0de37a2d0 100644
--- a/internal/test/config.go
+++ b/internal/test/config.go
@@ -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
 }