Files
stash/pkg/models/model_file.go
WithoutPants 39fdde273d Scan refactor (#1816)
* Add file scanner
* Scan scene changes
* Split scan files
* Generalise scan
* Refactor ffprobe
* Refactor ffmpeg encoder
* Move scene scan code to scene package
* Move matchExtension to utils
* Refactor gallery scanning
* Refactor image scanning
* Prevent race conditions on identical hashes
* Refactor image thumbnail generation
* Perform count concurrently
* Allow progress increment before total set
* Make progress updates more frequent
2021-10-15 10:39:48 +11:00

31 lines
922 B
Go

package models
import "time"
type File struct {
Checksum string `db:"checksum" json:"checksum"`
OSHash string `db:"oshash" json:"oshash"`
Path string `db:"path" json:"path"`
Size string `db:"size" json:"size"`
FileModTime time.Time `db:"file_mod_time" json:"file_mod_time"`
}
// GetHash returns the hash of the scene, based on the hash algorithm provided. If
// hash algorithm is MD5, then Checksum is returned. Otherwise, OSHash is returned.
func (s File) GetHash(hashAlgorithm HashAlgorithm) string {
var ret string
if hashAlgorithm == HashAlgorithmMd5 {
ret = s.Checksum
} else if hashAlgorithm == HashAlgorithmOshash {
ret = s.OSHash
} else {
panic("unknown hash algorithm")
}
return ret
}
func (s File) Equal(o File) bool {
return s.Path == o.Path && s.Checksum == o.Checksum && s.OSHash == o.OSHash && s.Size == o.Size && s.FileModTime.Equal(o.FileModTime)
}