diff --git a/internal/photoprism/index_mediafile.go b/internal/photoprism/index_mediafile.go index 5d2bff332..c31590c07 100644 --- a/internal/photoprism/index_mediafile.go +++ b/internal/photoprism/index_mediafile.go @@ -468,7 +468,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) ( photo.PhotoExposure = m.Exposure() } - if photo.TakenAt.IsZero() || photo.TakenAtLocal.IsZero() { + if photo.TakenSrc == entity.SrcAuto { takenUtc, takenSrc := m.TakenAt() photo.SetTakenAt(takenUtc, takenUtc, "", takenSrc) } diff --git a/internal/photoprism/mediafile_test.go b/internal/photoprism/mediafile_test.go index 923b3b199..d45a06c7f 100644 --- a/internal/photoprism/mediafile_test.go +++ b/internal/photoprism/mediafile_test.go @@ -67,7 +67,26 @@ func TestMediaFile_DateCreated(t *testing.T) { func TestMediaFile_TakenAt(t *testing.T) { conf := config.TestConfig() + t.Run("testdata/2018-04-12 19:24:49.gif", func(t *testing.T) { + mediaFile, err := NewMediaFile("testdata/2018-04-12 19:24:49.gif") + if err != nil { + t.Fatal(err) + } + date, src := mediaFile.TakenAt() + assert.Equal(t, "2018-04-12 19:24:49 +0000 UTC", date.String()) + assert.Equal(t, entity.SrcName, src) + }) + t.Run("testdata/2018-04-12 19:24:49.jpg", func(t *testing.T) { + mediaFile, err := NewMediaFile("testdata/2018-04-12 19:24:49.jpg") + if err != nil { + t.Fatal(err) + } + + date, src := mediaFile.TakenAt() + assert.Equal(t, "2018-04-12 19:24:49 +0000 UTC", date.String()) + assert.Equal(t, entity.SrcName, src) + }) t.Run("telegram_2020-01-30_09-57-18.jpg", func(t *testing.T) { mediaFile, err := NewMediaFile(conf.ExamplesPath() + "/telegram_2020-01-30_09-57-18.jpg") if err != nil { diff --git a/internal/photoprism/testdata/2018-04-12 19:24:49.gif b/internal/photoprism/testdata/2018-04-12 19:24:49.gif new file mode 100644 index 000000000..d5326632e Binary files /dev/null and b/internal/photoprism/testdata/2018-04-12 19:24:49.gif differ diff --git a/internal/photoprism/testdata/2018-04-12 19:24:49.jpg b/internal/photoprism/testdata/2018-04-12 19:24:49.jpg new file mode 100644 index 000000000..77a71cd9a Binary files /dev/null and b/internal/photoprism/testdata/2018-04-12 19:24:49.jpg differ diff --git a/internal/photoprism/testdata/2018-04-12 19:24:49.json b/internal/photoprism/testdata/2018-04-12 19:24:49.json new file mode 100755 index 000000000..7d0926e97 --- /dev/null +++ b/internal/photoprism/testdata/2018-04-12 19:24:49.json @@ -0,0 +1,29 @@ +[{ + "SourceFile": "/go/src/github.com/photoprism/photoprism/storage/originals/Debug/2018-04-12 19:24:49.gif", + "ExifToolVersion": 10.80, + "FileName": "2018-04-12 19:24:49.gif", + "Directory": "/go/src/github.com/photoprism/photoprism/storage/originals/Debug", + "FileSize": "4.9 MB", + "FileModifyDate": "2020:07:13 16:41:17+00:00", + "FileAccessDate": "2020:07:13 16:45:39+00:00", + "FileInodeChangeDate": "2020:07:13 16:45:37+00:00", + "FilePermissions": "rw-r--r--", + "FileType": "GIF", + "FileTypeExtension": "gif", + "MIMEType": "image/gif", + "GIFVersion": "89a", + "ImageWidth": 640, + "ImageHeight": 480, + "HasColorMap": "No", + "ColorResolutionDepth": 8, + "BitsPerPixel": 8, + "BackgroundColor": 0, + "AnimationIterations": "Infinite", + "XMPToolkit": "Adobe XMP Core 5.1.0-jc003", + "CameraBurstID": "830cb602-95b4-4c2e-aed3-0ce827b226de", + "Type": "GCameraAnimation", + "FrameCount": 35, + "Duration": "2.25 s", + "ImageSize": "640x480", + "Megapixels": 0.307 +}] diff --git a/pkg/txt/convert_test.go b/pkg/txt/convert_test.go index 0863eb2aa..6e06a14c6 100644 --- a/pkg/txt/convert_test.go +++ b/pkg/txt/convert_test.go @@ -13,6 +13,12 @@ func TestTime(t *testing.T) { assert.Equal(t, "2018-04-12 19:24:49 +0000 UTC", result.String()) }) + t.Run("2018-04-12 19/24/49.gif", func(t *testing.T) { + result := Time("2018-04-12 19/24/49.gif") + assert.False(t, result.IsZero()) + assert.Equal(t, "2018-04-12 19:24:49 +0000 UTC", result.String()) + }) + t.Run("/2020/1212/20130518_142022_3D657EBD.jpg", func(t *testing.T) { result := Time("/2020/1212/20130518_142022_3D657EBD.jpg") //assert.False(t, result.IsZero())