photoprism/internal/entity/entity.go
Michael Mayer e43983d579 Backend: Refactor thumbnail package #157
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
2020-01-06 14:32:15 +01:00

38 lines
848 B
Go

/*
This package contains models for data storage based on GORM.
See http://gorm.io/docs/ for more information about GORM.
Additional information concerning data storage can be found in our Developer Guide:
https://github.com/photoprism/photoprism/wiki/Storage
*/
package entity
import (
"strconv"
"sync"
"time"
"github.com/jinzhu/gorm"
"github.com/photoprism/photoprism/internal/event"
"github.com/photoprism/photoprism/internal/rnd"
)
var log = event.Log
var writeMutex = sync.Mutex{}
func logError(result *gorm.DB) {
if result.Error != nil {
log.Error(result.Error.Error())
}
}
func ID(prefix rune) string {
result := make([]byte, 0, 17)
result = append(result, byte(prefix))
result = append(result, strconv.FormatInt(time.Now().UTC().Unix(), 36)[0:6]...)
result = append(result, rnd.Token(10)...)
return string(result)
}