Rename Config.GetImportPath() to ImportPath(), see #50

This commit is contained in:
Michael Mayer 2018-12-21 03:21:49 +01:00
parent c1219799da
commit 1a4815fd51
20 changed files with 46 additions and 46 deletions

View file

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

View file

@ -25,7 +25,7 @@ func importAction(ctx *cli.Context) error {
conf.MigrateDb()
fmt.Printf("Importing photos from %s...\n", conf.GetImportPath())
fmt.Printf("Importing photos from %s...\n", conf.ImportPath())
tensorFlow := photoprism.NewTensorFlow(conf.GetTensorFlowModelPath())
@ -35,7 +35,7 @@ func importAction(ctx *cli.Context) error {
importer := photoprism.NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())
importer.ImportPhotosFromDirectory(conf.ImportPath())
fmt.Println("Done.")

View file

@ -217,7 +217,7 @@ func (c *Config) CreateDirectories() error {
return err
}
if err := os.MkdirAll(c.GetImportPath(), os.ModePerm); err != nil {
if err := os.MkdirAll(c.ImportPath(), os.ModePerm); err != nil {
return err
}
@ -351,8 +351,8 @@ func (c *Config) OriginalsPath() string {
return c.originalsPath
}
// GetImportPath returns the import directory.
func (c *Config) GetImportPath() string {
// ImportPath returns the import directory.
func (c *Config) ImportPath() string {
return c.importPath
}

View file

@ -32,7 +32,7 @@ func TestConfig_SetValuesFromFile(t *testing.T) {
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.OriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.ImportPath())
assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath())
assert.Equal(t, "tidb", c.DatabaseDriver())
assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn())

View file

@ -14,7 +14,7 @@ func TestMediaFile_GetColors_Slow(t *testing.T) {
conf.InitializeTestData(t)
if mediaFile2, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG"); err == nil {
if mediaFile2, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err == nil {
names, vibrantHex, mutedHex := mediaFile2.GetColors()
@ -26,7 +26,7 @@ func TestMediaFile_GetColors_Slow(t *testing.T) {
t.Error(err)
}
if mediaFile3, err := NewMediaFile(conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"); err == nil {
if mediaFile3, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"); err == nil {
names, vibrantHex, mutedHex := mediaFile3.GetColors()

View file

@ -12,7 +12,7 @@ func TestMediaFile_GetColors(t *testing.T) {
conf.InitializeTestData(t)
if mediaFile1, err := NewMediaFile(conf.GetImportPath() + "/dog.jpg"); err == nil {
if mediaFile1, err := NewMediaFile(conf.ImportPath() + "/dog.jpg"); err == nil {
names, vibrantHex, mutedHex := mediaFile1.GetColors()
t.Log(names, vibrantHex, mutedHex)

View file

@ -33,7 +33,7 @@ type Config interface {
DatabaseDsn() string
OriginalsPath() string
GetImportPath() string
ImportPath() string
GetExportPath() string
GetDarktableCli() string
GetCachePath() string

View file

@ -56,7 +56,7 @@ func TestContextConfig_SetValuesFromFile(t *testing.T) {
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.OriginalsPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath())
assert.Equal(t, "/srv/photoprism/photos/import", c.ImportPath())
assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath())
assert.Equal(t, "tidb", c.DatabaseDriver())
assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn())

View file

@ -18,7 +18,7 @@ func TestConverter_ConvertToJpeg(t *testing.T) {
converter := NewConverter(conf.GetDarktableCli())
jpegFilename := conf.GetImportPath() + "/iphone/IMG_6788.JPG"
jpegFilename := conf.ImportPath() + "/iphone/IMG_6788.JPG"
assert.Truef(t, fsutil.Exists(jpegFilename), "file does not exist: %s", jpegFilename)
@ -42,7 +42,7 @@ func TestConverter_ConvertToJpeg(t *testing.T) {
assert.Equal(t, "iPhone SE", infoJpeg.CameraModel)
rawFilemame := conf.GetImportPath() + "/raw/IMG_1435.CR2"
rawFilemame := conf.ImportPath() + "/raw/IMG_1435.CR2"
t.Logf("Testing RAW to JPEG converter with %s", rawFilemame)
@ -52,7 +52,7 @@ func TestConverter_ConvertToJpeg(t *testing.T) {
imageRaw, _ := converter.ConvertToJpeg(rawMediaFile)
assert.True(t, fsutil.Exists(conf.GetImportPath()+"/raw/IMG_1435.jpg"), "Jpeg file was not found - is Darktable installed?")
assert.True(t, fsutil.Exists(conf.ImportPath()+"/raw/IMG_1435.jpg"), "Jpeg file was not found - is Darktable installed?")
assert.NotEqual(t, rawFilemame, imageRaw.filename)
@ -70,9 +70,9 @@ func TestConverter_ConvertAll(t *testing.T) {
converter := NewConverter(conf.GetDarktableCli())
converter.ConvertAll(conf.GetImportPath())
converter.ConvertAll(conf.ImportPath())
jpegFilename := conf.GetImportPath() + "/raw/IMG_1435.jpg"
jpegFilename := conf.ImportPath() + "/raw/IMG_1435.jpg"
assert.True(t, fsutil.Exists(jpegFilename), "Jpeg file was not found - is Darktable installed?")
@ -88,13 +88,13 @@ func TestConverter_ConvertAll(t *testing.T) {
assert.Equal(t, "Canon EOS M10", infoRaw.CameraModel, "Camera model should be Canon EOS M10")
existingJpegFilename := conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"
existingJpegFilename := conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg"
oldHash := fsutil.Hash(existingJpegFilename)
os.Remove(existingJpegFilename)
converter.ConvertAll(conf.GetImportPath())
converter.ConvertAll(conf.ImportPath())
newHash := fsutil.Hash(existingJpegFilename)

View file

@ -14,7 +14,7 @@ func TestMediaFile_GetExifData_Slow(t *testing.T) {
conf.InitializeTestData(t)
image2, err := NewMediaFile(conf.GetImportPath() + "/raw/IMG_1435.CR2")
image2, err := NewMediaFile(conf.ImportPath() + "/raw/IMG_1435.CR2")
assert.Nil(t, err)

View file

@ -12,7 +12,7 @@ func TestMediaFile_GetExifData(t *testing.T) {
conf.InitializeTestData(t)
image1, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
image1, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)

View file

@ -21,5 +21,5 @@ func TestImporter_ImportPhotosFromDirectory(t *testing.T) {
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())
importer.ImportPhotosFromDirectory(conf.ImportPath())
}

View file

@ -33,7 +33,7 @@ func TestImporter_GetDestinationFilename(t *testing.T) {
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
rawFile, err := NewMediaFile(conf.GetImportPath() + "/raw/IMG_1435.CR2")
rawFile, err := NewMediaFile(conf.ImportPath() + "/raw/IMG_1435.CR2")
assert.Nil(t, err)

View file

@ -14,13 +14,13 @@ func TestMediaFile_GetPerceptiveHash_Slow(t *testing.T) {
conf.InitializeTestData(t)
mediaFile1, err := NewMediaFile(conf.GetImportPath() + "/20130203_193332_0AE340D280.jpg")
mediaFile1, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280.jpg")
assert.Nil(t, err)
hash1, _ := mediaFile1.GetPerceptualHash()
assert.Equal(t, "ef95", hash1)
mediaFile2, err := NewMediaFile(conf.GetImportPath() + "/20130203_193332_0AE340D280_V2.jpg")
mediaFile2, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280_V2.jpg")
assert.Nil(t, err)
hash2, _ := mediaFile2.GetPerceptualHash()
@ -30,7 +30,7 @@ func TestMediaFile_GetPerceptiveHash_Slow(t *testing.T) {
assert.Equal(t, 1, distance)
mediaFile3, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
mediaFile3, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
hash3, _ := mediaFile3.GetPerceptualHash()

View file

@ -12,11 +12,11 @@ func TestMediaFile_GetRelatedFiles(t *testing.T) {
conf.InitializeTestData(t)
mediaFile, err := NewMediaFile(conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489.cr2")
mediaFile, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.cr2")
assert.Nil(t, err)
expectedBaseFilename := conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489"
expectedBaseFilename := conf.ImportPath() + "/raw/20140717_154212_1EC48F8489"
related, _, err := mediaFile.GetRelatedFiles()
@ -42,7 +42,7 @@ func TestMediaFile_GetRelatedFiles_Ordering(t *testing.T) {
conf.InitializeTestData(t)
mediaFile, err := NewMediaFile(conf.GetImportPath() + "/20130203_193332_0AE340D280.jpg")
mediaFile, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280.jpg")
assert.Nil(t, err)
@ -63,9 +63,9 @@ func TestMediaFile_GetEditedFilename(t *testing.T) {
conf.InitializeTestData(t)
mediaFile1, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
mediaFile1, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
assert.Equal(t, conf.GetImportPath()+"/iphone/IMG_E6788.JPG", mediaFile1.GetEditedFilename())
assert.Equal(t, conf.ImportPath()+"/iphone/IMG_E6788.JPG", mediaFile1.GetEditedFilename())
/* TODO: Add example files to import.zip
mediaFile2, err := NewMediaFile("/foo/bar/IMG_E1234.jpg")
@ -73,7 +73,7 @@ func TestMediaFile_GetEditedFilename(t *testing.T) {
assert.Equal(t, "", mediaFile2.GetEditedFilename())
*/
mediaFile3, err := NewMediaFile(conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489.jpg")
mediaFile3, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.jpg")
assert.Nil(t, err)
assert.Equal(t, "", mediaFile3.GetEditedFilename())
}
@ -83,7 +83,7 @@ func TestMediaFile_GetPerceptiveHash(t *testing.T) {
conf.InitializeTestData(t)
mediaFile1, err := NewMediaFile(conf.GetImportPath() + "/20130203_193332_0AE340D280.jpg")
mediaFile1, err := NewMediaFile(conf.ImportPath() + "/20130203_193332_0AE340D280.jpg")
assert.Nil(t, err)
hash1, _ := mediaFile1.GetPerceptualHash()
@ -99,11 +99,11 @@ func TestMediaFile_GetMimeType(t *testing.T) {
conf.InitializeTestData(t)
image1, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
image1, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
assert.Equal(t, "image/jpeg", image1.GetMimeType())
image2, err := NewMediaFile(conf.GetImportPath() + "/raw/20140717_154212_1EC48F8489.cr2")
image2, err := NewMediaFile(conf.ImportPath() + "/raw/20140717_154212_1EC48F8489.cr2")
assert.Nil(t, err)
assert.Equal(t, "application/octet-stream", image2.GetMimeType())
}
@ -111,12 +111,12 @@ func TestMediaFile_GetMimeType(t *testing.T) {
func TestMediaFile_Exists(t *testing.T) {
conf := test.NewConfig()
mediaFile, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
mediaFile, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
assert.NotNil(t, mediaFile)
assert.True(t, mediaFile.Exists())
mediaFile, err = NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788_XYZ.JPG")
mediaFile, err = NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788_XYZ.JPG")
assert.NotNil(t, err)
assert.Nil(t, mediaFile)
}

View file

@ -17,7 +17,7 @@ func TestTensorFlow_GetImageTags(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
if imageBuffer, err := ioutil.ReadFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG"); err != nil {
if imageBuffer, err := ioutil.ReadFile(conf.ImportPath() + "/iphone/IMG_6788.JPG"); err != nil {
t.Error(err)
} else {
result, err := tensorFlow.GetImageTags(string(imageBuffer))

View file

@ -14,7 +14,7 @@ func TestTensorFlow_GetImageTagsFromFile(t *testing.T) {
tensorFlow := NewTensorFlow(conf.GetTensorFlowModelPath())
result, err := tensorFlow.GetImageTagsFromFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
result, err := tensorFlow.GetImageTagsFromFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.NotNil(t, result)
assert.Nil(t, err)

View file

@ -23,7 +23,7 @@ func TestCreateThumbnailsFromOriginals(t *testing.T) {
importer := NewImporter(conf.OriginalsPath(), indexer, converter)
importer.ImportPhotosFromDirectory(conf.GetImportPath())
importer.ImportPhotosFromDirectory(conf.ImportPath())
CreateThumbnailsFromOriginals(conf.OriginalsPath(), conf.GetThumbnailsPath(), 600, false)

View file

@ -14,7 +14,7 @@ func TestMediaFile_GetThumbnail(t *testing.T) {
conf.InitializeTestData(t)
image1, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
image1, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
thumbnail1, err := image1.GetThumbnail(conf.GetThumbnailsPath(), 350)
@ -31,7 +31,7 @@ func TestMediaFile_GetSquareThumbnail(t *testing.T) {
conf.InitializeTestData(t)
image1, err := NewMediaFile(conf.GetImportPath() + "/iphone/IMG_6788.JPG")
image1, err := NewMediaFile(conf.ImportPath() + "/iphone/IMG_6788.JPG")
assert.Nil(t, err)
thumbnail1, err := image1.GetSquareThumbnail(conf.GetThumbnailsPath(), 350)

View file

@ -42,7 +42,7 @@ type Config struct {
}
func (c *Config) RemoveTestData(t *testing.T) {
os.RemoveAll(c.GetImportPath())
os.RemoveAll(c.ImportPath())
os.RemoveAll(c.GetExportPath())
os.RemoveAll(c.OriginalsPath())
os.RemoveAll(c.GetCachePath())
@ -97,7 +97,7 @@ func (c *Config) CreateDirectories() error {
return err
}
if err := os.MkdirAll(c.GetImportPath(), os.ModePerm); err != nil {
if err := os.MkdirAll(c.ImportPath(), os.ModePerm); err != nil {
return err
}
@ -208,8 +208,8 @@ func (c *Config) OriginalsPath() string {
return OriginalsPath
}
// GetImportPath returns the import directory.
func (c *Config) GetImportPath() string {
// ImportPath returns the import directory.
func (c *Config) ImportPath() string {
return ImportPath
}