Index: Truncate mod time to full seconds #2257
This commit is contained in:
parent
9e5b2178cf
commit
54700766df
9 changed files with 16 additions and 11 deletions
|
@ -280,7 +280,7 @@ func (m File) Changed(fileSize int64, modTime time.Time) bool {
|
|||
}
|
||||
|
||||
// Modification time has changed.
|
||||
if m.ModTime == modTime.Unix() {
|
||||
if m.ModTime == modTime.UTC().Truncate(time.Second).Unix() {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func (m *Photo) SetTakenAt(taken, local time.Time, zone, source string) {
|
|||
}
|
||||
|
||||
// Round times to avoid jitter.
|
||||
taken = taken.Truncate(time.Second).UTC()
|
||||
taken = taken.UTC().Truncate(time.Second)
|
||||
|
||||
// Default local time to taken if zero or invalid.
|
||||
if local.IsZero() || local.Year() < 1000 {
|
||||
|
|
|
@ -150,7 +150,7 @@ func (data *Data) GPhoto(jsonData []byte) (err error) {
|
|||
if loc, err := time.LoadLocation(data.TimeZone); err != nil {
|
||||
log.Warnf("metadata: unknown time zone %s (gphotos)", data.TimeZone)
|
||||
} else if tl, err := time.ParseInLocation("2006:01:02 15:04:05", data.TakenAtLocal.Format("2006:01:02 15:04:05"), loc); err == nil {
|
||||
data.TakenAt = tl.Truncate(time.Second).UTC()
|
||||
data.TakenAt = tl.UTC().Truncate(time.Second)
|
||||
} else {
|
||||
log.Errorf("metadata: %s (gphotos)", err.Error()) // this should never happen
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func (m *Files) Remove(fileName, fileRoot string) {
|
|||
|
||||
// Ignore tests of a file requires indexing, file name must be relative to the originals path.
|
||||
func (m *Files) Ignore(fileName, fileRoot string, modTime time.Time, rescan bool) bool {
|
||||
timestamp := modTime.Unix()
|
||||
timestamp := modTime.UTC().Truncate(time.Second).Unix()
|
||||
key := path.Join(fileRoot, fileName)
|
||||
|
||||
m.mutex.Lock()
|
||||
|
|
|
@ -38,7 +38,8 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
// Extract metadata to a JSON file with Exiftool.
|
||||
if related.Main.NeedsExifToolJson() {
|
||||
if jsonName, err := imp.convert.ToJson(related.Main); err != nil {
|
||||
log.Debugf("import: %s in %s (extract metadata)", clean.Log(err.Error()), clean.Log(related.Main.BaseName()))
|
||||
log.Tracef("exiftool: %s", clean.Log(err.Error()))
|
||||
log.Debugf("exiftool: failed parsing %s", clean.Log(related.Main.RootRelName()))
|
||||
} else if err := related.Main.ReadExifToolJson(); err != nil {
|
||||
log.Errorf("import: %s in %s (read metadata)", clean.Log(err.Error()), clean.Log(related.Main.BaseName()))
|
||||
} else {
|
||||
|
@ -127,7 +128,8 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
// Extract metadata to a JSON file with Exiftool.
|
||||
if f.NeedsExifToolJson() {
|
||||
if jsonName, err := imp.convert.ToJson(f); err != nil {
|
||||
log.Debugf("import: %s in %s (extract metadata)", clean.Log(err.Error()), clean.Log(f.RootRelName()))
|
||||
log.Tracef("exiftool: %s", clean.Log(err.Error()))
|
||||
log.Debugf("exiftool: failed parsing %s", clean.Log(f.RootRelName()))
|
||||
} else {
|
||||
log.Debugf("import: created %s", filepath.Base(jsonName))
|
||||
}
|
||||
|
@ -222,7 +224,8 @@ func ImportWorker(jobs <-chan ImportJob) {
|
|||
// Extract metadata to a JSON file with Exiftool.
|
||||
if f.NeedsExifToolJson() {
|
||||
if jsonName, err := imp.convert.ToJson(f); err != nil {
|
||||
log.Debugf("import: %s in %s (extract metadata)", clean.Log(err.Error()), clean.Log(f.RootRelName()))
|
||||
log.Tracef("exiftool: %s", clean.Log(err.Error()))
|
||||
log.Debugf("exiftool: failed parsing %s", clean.Log(f.RootRelName()))
|
||||
} else {
|
||||
log.Debugf("import: created %s", filepath.Base(jsonName))
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ func IndexMain(related *RelatedFiles, ind *Index, o IndexOptions) (result IndexR
|
|||
// Extract metadata to a JSON file with Exiftool.
|
||||
if f.NeedsExifToolJson() {
|
||||
if jsonName, err := ind.convert.ToJson(f); err != nil {
|
||||
log.Debugf("index: %s in %s (extract metadata)", clean.Log(err.Error()), clean.Log(f.RootRelName()))
|
||||
log.Tracef("exiftool: %s", clean.Log(err.Error()))
|
||||
log.Debugf("exiftool: failed parsing %s", clean.Log(f.RootRelName()))
|
||||
} else {
|
||||
log.Debugf("index: created %s", filepath.Base(jsonName))
|
||||
}
|
||||
|
|
|
@ -672,7 +672,7 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName, photoUID
|
|||
file.MediaType = m.Media().String()
|
||||
file.FileMime = m.MimeType()
|
||||
file.FileOrientation = m.Orientation()
|
||||
file.ModTime = modTime.Unix()
|
||||
file.ModTime = modTime.UTC().Truncate(time.Second).Unix()
|
||||
|
||||
// Detect ICC color profile for JPEGs if still unknown at this point.
|
||||
if file.FileColorProfile == "" && fs.ImageJPEG.Equal(file.FileType) {
|
||||
|
|
|
@ -61,7 +61,8 @@ func IndexRelated(related RelatedFiles, ind *Index, o IndexOptions) (result Inde
|
|||
// Extract metadata to a JSON file with Exiftool.
|
||||
if f.NeedsExifToolJson() {
|
||||
if jsonName, err := ind.convert.ToJson(f); err != nil {
|
||||
log.Debugf("index: %s in %s (extract metadata)", clean.Log(err.Error()), clean.Log(f.RootRelName()))
|
||||
log.Tracef("exiftool: %s", clean.Log(err.Error()))
|
||||
log.Debugf("exiftool: failed parsing %s", clean.Log(f.RootRelName()))
|
||||
} else {
|
||||
log.Debugf("index: created %s", filepath.Base(jsonName))
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ func (m *MediaFile) Stat() (size int64, mod time.Time, err error) {
|
|||
m.fileSize = -1
|
||||
} else {
|
||||
m.statErr = nil
|
||||
m.modTime = s.ModTime().Truncate(time.Second)
|
||||
m.modTime = s.ModTime().UTC().Truncate(time.Second)
|
||||
m.fileSize = s.Size()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue