Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c32c6db3ae |
No files matched your search
@@ -173,8 +173,8 @@ has:
|
||||
The primary member is the first of these that the group holds:
|
||||
|
||||
1. a `JPG` file
|
||||
2. any other file in `Store.Images`
|
||||
3. a file in `Store.Videos`
|
||||
2. any other image
|
||||
3. a video
|
||||
4. any other file except a `THM`
|
||||
5. a `THM`
|
||||
|
||||
|
||||
+1
-1
@@ -235,7 +235,7 @@ func parseStores(mountpoints []string) ([]Store, error) {
|
||||
|
||||
func isImageFile(path string) bool {
|
||||
imageExtensions := []string{
|
||||
".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tif", ".tiff", ".raw", ".arw",
|
||||
".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".raw", ".arw",
|
||||
}
|
||||
|
||||
return slices.Contains(imageExtensions, strings.ToLower(filepath.Ext(path)))
|
||||
|
||||
@@ -62,8 +62,6 @@ func TestIsImageFile(t *testing.T) {
|
||||
cases := map[string]bool{
|
||||
"DCIM/100MSDCF/DSC00001.jpg": true,
|
||||
"DCIM/100MSDCF/DSC00001.ARW": true,
|
||||
"DCIM/100MSDCF/DSC00001.TIF": true,
|
||||
"DCIM/100MSDCF/DSC00001.tif": true,
|
||||
"PRIVATE/M4ROOT/CLIP/C0001.MP4": false,
|
||||
"DCIM/100MSDCF/notes.txt": false,
|
||||
"DCIM/100MSDCF/noextension": false,
|
||||
|
||||
@@ -42,12 +42,10 @@ func newFileGroups(objects []*Object) []*FileGroup {
|
||||
}
|
||||
|
||||
// primaryMember returns the member that stands for the whole group. Section
|
||||
// 6.2.1.3 of the specification gives a DCF basic file priority over a DCF extended
|
||||
// image file. It says nothing about a DCF optional file, the other kind of JPG, so
|
||||
// ranking every JPG first is a choice. Section 4.6 makes a THM only the thumbnail
|
||||
// of another file, so it comes last. The specification leaves the rest open, so an
|
||||
// image comes before a video, and a video before any other file. Among equals, the
|
||||
// first in name order wins.
|
||||
// 6.2.1.3 of the specification gives a JPG priority over the other files. Section
|
||||
// 4.6 makes a THM only the thumbnail of another file, so it comes last. The
|
||||
// specification leaves the rest open, so an image comes before a video, and a
|
||||
// video before any other file. Among equals, the first in name order wins.
|
||||
func primaryMember(members []*Object) *Object {
|
||||
choices := []func(string) bool{isJPG, isImageFile, isVideoFile, isNotTHM}
|
||||
|
||||
|
||||
@@ -212,16 +212,14 @@ func TestPrimaryMember(t *testing.T) {
|
||||
// Then any other image.
|
||||
assertPrimaryMember(t, "Z0010001.ARW", "A0010001.MP4", "Z0010001.ARW")
|
||||
assertPrimaryMember(t, "Z0010001.ARW", "A0010001.WAV", "Z0010001.ARW")
|
||||
assertPrimaryMember(t, "A0010001.TIF", "A0010001.MOV", "A0010001.TIF")
|
||||
assertPrimaryMember(t, "Z0010001.TIF", "A0010001.WAV", "Z0010001.TIF")
|
||||
|
||||
// Then a video.
|
||||
assertPrimaryMember(t, "A0010001.MP4", "A0010001.AAC", "A0010001.MP4")
|
||||
assertPrimaryMember(t, "Z0010001.MP4", "A0010001.THM", "Z0010001.MP4")
|
||||
|
||||
// Then any other file except a THM, in either case.
|
||||
assertPrimaryMember(t, "Z0010001.WAV", "A0010001.THM", "Z0010001.WAV")
|
||||
assertPrimaryMember(t, "a0010001.wav", "a0010001.thm", "a0010001.wav")
|
||||
assertPrimaryMember(t, "Z0010001.TIF", "A0010001.THM", "Z0010001.TIF")
|
||||
assertPrimaryMember(t, "a0010001.tif", "a0010001.thm", "a0010001.tif")
|
||||
|
||||
// A THM is primary only when the group holds nothing else.
|
||||
assertPrimaryMember(t, "A0010001.THM", "A0010001.THM")
|
||||
|
||||
Reference in new issue
Block a user