photoprism/internal/photoprism/mediafiles.go
Michael Mayer a4070cf55c Backend: Store and index original file names during import #184
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-02-01 20:52:28 +01:00

27 lines
570 B
Go

package photoprism
// MediaFiles represents a slice of files.
type MediaFiles []*MediaFile
// Len returns the length of the file slice.
func (f MediaFiles) Len() int {
return len(f)
}
// Less compares two files based on the filename.
func (f MediaFiles) Less(i, j int) bool {
fileName1 := f[i].FileName()
fileName2 := f[j].FileName()
if len(fileName1) == len(fileName2) {
return fileName1 < fileName2
}
return len(fileName1) < len(fileName2)
}
// Swap the position of two files in the slice.
func (f MediaFiles) Swap(i, j int) {
f[i], f[j] = f[j], f[i]
}