Skip exact duplicates #283
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
96ec67f868
commit
3b27f8d3f4
3 changed files with 15 additions and 8 deletions
|
@ -92,9 +92,9 @@ func (m File) Changed(fileSize int64, fileModified time.Time) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
if m.FileModified.Format("2006-01-02 15:04:05") != fileModified.Format("2006-01-02 15:04:05") {
|
||||
return true
|
||||
if m.FileModified.Round(time.Second).Equal(fileModified.Round(time.Second)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -13,14 +13,16 @@ import (
|
|||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/photoprism/photoprism/internal/event"
|
||||
"github.com/photoprism/photoprism/internal/meta"
|
||||
"github.com/photoprism/photoprism/pkg/fs"
|
||||
"github.com/photoprism/photoprism/pkg/txt"
|
||||
)
|
||||
|
||||
const (
|
||||
IndexUpdated IndexStatus = "updated"
|
||||
IndexAdded IndexStatus = "added"
|
||||
IndexSkipped IndexStatus = "skipped"
|
||||
IndexFailed IndexStatus = "failed"
|
||||
IndexUpdated IndexStatus = "updated"
|
||||
IndexAdded IndexStatus = "added"
|
||||
IndexSkipped IndexStatus = "skipped"
|
||||
IndexDuplicate IndexStatus = "skipped duplicate"
|
||||
IndexFailed IndexStatus = "failed"
|
||||
)
|
||||
|
||||
type IndexStatus string
|
||||
|
@ -84,6 +86,11 @@ func (ind *Index) MediaFile(m *MediaFile, o IndexOptions, originalName string) (
|
|||
fileHash = m.Hash()
|
||||
fileQuery = ind.db.Unscoped().First(&file, "file_hash = ?", fileHash)
|
||||
fileExists = fileQuery.Error == nil
|
||||
|
||||
if fileExists && fs.FileExists(filepath.Join(ind.conf.OriginalsPath(), file.FileName)) {
|
||||
result.Status = IndexDuplicate
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
if !fileExists {
|
||||
|
|
|
@ -59,7 +59,7 @@ func (m MediaFile) Stat() (size int64, mod time.Time) {
|
|||
return -1, time.Now()
|
||||
}
|
||||
|
||||
return s.Size(), s.ModTime()
|
||||
return s.Size(), s.ModTime().Round(time.Second)
|
||||
}
|
||||
|
||||
// DateCreated returns the date on which the media file was created in UTC.
|
||||
|
|
Loading…
Reference in a new issue