mirror of https://github.com/dsoprea/go-exif.git
tags.go: Serialized adds/gets on index
https://github.com/photoprism/photoprism/issues/600dustin/add_float_and_double
parent
de21411905
commit
b3f4f3b4b7
|
@ -2,6 +2,7 @@ package exif
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/dsoprea/go-logging"
|
||||
"gopkg.in/yaml.v2"
|
||||
|
@ -177,6 +178,8 @@ func (it *IndexedTag) DoesSupportType(tagType exifcommon.TagTypePrimitive) bool
|
|||
type TagIndex struct {
|
||||
tagsByIfd map[string]map[uint16]*IndexedTag
|
||||
tagsByIfdR map[string]map[string]*IndexedTag
|
||||
|
||||
mutex sync.Mutex
|
||||
}
|
||||
|
||||
// NewTagIndex returns a new TagIndex struct.
|
||||
|
@ -197,6 +200,9 @@ func (ti *TagIndex) Add(it *IndexedTag) (err error) {
|
|||
}
|
||||
}()
|
||||
|
||||
ti.mutex.Lock()
|
||||
defer ti.mutex.Unlock()
|
||||
|
||||
// Store by ID.
|
||||
|
||||
family, found := ti.tagsByIfd[it.IfdPath]
|
||||
|
@ -242,6 +248,9 @@ func (ti *TagIndex) Get(ii *exifcommon.IfdIdentity, id uint16) (it *IndexedTag,
|
|||
log.PanicIf(err)
|
||||
}
|
||||
|
||||
ti.mutex.Lock()
|
||||
defer ti.mutex.Unlock()
|
||||
|
||||
ifdPath := ii.UnindexedString()
|
||||
|
||||
family, found := ti.tagsByIfd[ifdPath]
|
||||
|
|
Loading…
Reference in New Issue