Shorten unique IDs
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
2f4840f9c2
commit
54d33e2a43
6 changed files with 12 additions and 12 deletions
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
// Data represents image meta data.
|
||||
type Data struct {
|
||||
UUID string
|
||||
UniqueID string
|
||||
TakenAt time.Time
|
||||
TakenAtLocal time.Time
|
||||
TimeZone string
|
||||
|
|
|
@ -192,7 +192,7 @@ func Exif(filename string) (data Data, err error) {
|
|||
}
|
||||
|
||||
if value, ok := tags["ImageUniqueID"]; ok {
|
||||
data.UUID = value
|
||||
data.UniqueID = value
|
||||
}
|
||||
|
||||
if value, ok := tags["ImageWidth"]; ok {
|
||||
|
|
|
@ -104,10 +104,10 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions) IndexResult {
|
|||
photo.PhotoAltitude = metaData.Altitude
|
||||
photo.PhotoArtist = metaData.Artist
|
||||
|
||||
if len(metaData.UUID) > 15 {
|
||||
log.Debugf("index: file uuid \"%s\"", metaData.UUID)
|
||||
if len(metaData.UniqueID) > 15 {
|
||||
log.Debugf("index: file uuid \"%s\"", metaData.UniqueID)
|
||||
|
||||
file.FileUUID = metaData.UUID
|
||||
file.FileUUID = metaData.UniqueID
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestMediaFile_Exif_JPEG(t *testing.T) {
|
|||
|
||||
assert.IsType(t, meta.Data{}, info)
|
||||
|
||||
assert.Equal(t, "", info.UUID)
|
||||
assert.Equal(t, "", info.UniqueID)
|
||||
assert.Equal(t, "2013-11-26 13:53:55 +0000 UTC", info.TakenAt.String())
|
||||
assert.Equal(t, "2013-11-26 15:53:55 +0000 UTC", info.TakenAtLocal.String())
|
||||
assert.Equal(t, 1, info.Orientation)
|
||||
|
@ -60,7 +60,7 @@ func TestMediaFile_Exif_JPEG(t *testing.T) {
|
|||
|
||||
assert.IsType(t, meta.Data{}, info)
|
||||
|
||||
assert.Equal(t, "", info.UUID)
|
||||
assert.Equal(t, "", info.UniqueID)
|
||||
assert.Equal(t, 1, info.Orientation)
|
||||
assert.Equal(t, "Canon EOS 7D", info.CameraModel)
|
||||
assert.Equal(t, "Canon", info.CameraMake)
|
||||
|
@ -100,7 +100,7 @@ func TestMediaFile_Exif_DNG(t *testing.T) {
|
|||
|
||||
assert.IsType(t, meta.Data{}, info)
|
||||
|
||||
assert.Equal(t, "", info.UUID)
|
||||
assert.Equal(t, "", info.UniqueID)
|
||||
assert.Equal(t, "2019-06-06 07:29:51 +0000 UTC", info.TakenAt.String())
|
||||
assert.Equal(t, "2019-06-06 07:29:51 +0000 UTC", info.TakenAtLocal.String())
|
||||
assert.Equal(t, 1, info.Orientation)
|
||||
|
@ -150,7 +150,7 @@ func TestMediaFile_Exif_HEIF(t *testing.T) {
|
|||
|
||||
assert.Nil(t, err)
|
||||
|
||||
assert.Equal(t, "", jpegInfo.UUID)
|
||||
assert.Equal(t, "", jpegInfo.UniqueID)
|
||||
assert.Equal(t, "2018-09-10 03:16:13 +0000 UTC", jpegInfo.TakenAt.String())
|
||||
assert.Equal(t, "2018-09-10 12:16:13 +0000 UTC", jpegInfo.TakenAtLocal.String())
|
||||
assert.Equal(t, 6, jpegInfo.Orientation)
|
||||
|
|
|
@ -7,10 +7,10 @@ import (
|
|||
|
||||
// PPID returns a unique id with prefix as string.
|
||||
func PPID(prefix rune) string {
|
||||
result := make([]byte, 0, 17)
|
||||
result := make([]byte, 0, 16)
|
||||
result = append(result, byte(prefix))
|
||||
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
|
||||
result = append(result, Token(10)...)
|
||||
result = append(result, Token(9)...)
|
||||
|
||||
return string(result)
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestPPID(t *testing.T) {
|
|||
for n := 0; n < 5; n++ {
|
||||
uuid := PPID('x')
|
||||
t.Logf("id: %s", uuid)
|
||||
assert.Equal(t, len(uuid), 17)
|
||||
assert.Equal(t, len(uuid), 16)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue