Backend: Log indexing duration for files
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
b78c95bc2b
commit
13536bb8b2
2 changed files with 7 additions and 0 deletions
|
@ -12,6 +12,8 @@ import (
|
|||
// An image or sidecar file that belongs to a photo
|
||||
type File struct {
|
||||
Model
|
||||
CreatedIn int64
|
||||
UpdatedIn int64
|
||||
Photo *Photo
|
||||
PhotoID uint `gorm:"index;"`
|
||||
PhotoUUID string `gorm:"index;"`
|
||||
|
|
|
@ -22,6 +22,8 @@ const (
|
|||
type IndexResult string
|
||||
|
||||
func (i *Indexer) indexMediaFile(m *MediaFile, o IndexerOptions) IndexResult {
|
||||
start := time.Now()
|
||||
|
||||
var photo entity.Photo
|
||||
var file, primaryFile entity.File
|
||||
var exifData *Exif
|
||||
|
@ -211,10 +213,13 @@ func (i *Indexer) indexMediaFile(m *MediaFile, o IndexerOptions) IndexResult {
|
|||
}
|
||||
|
||||
if fileQuery.Error == nil {
|
||||
file.UpdatedIn = int64(time.Since(start))
|
||||
i.db.Unscoped().Save(&file)
|
||||
return indexResultUpdated
|
||||
}
|
||||
|
||||
file.CreatedIn = int64(time.Since(start))
|
||||
|
||||
i.db.Create(&file)
|
||||
return indexResultAdded
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue