mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
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
This commit is contained in:
@@ -3,6 +3,7 @@ package models
|
||||
import (
|
||||
"database/sql"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Gallery struct {
|
||||
@@ -40,6 +41,40 @@ type GalleryPartial struct {
|
||||
UpdatedAt *SQLiteTimestamp `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (s *Gallery) File() File {
|
||||
ret := File{
|
||||
Path: s.Path.String,
|
||||
}
|
||||
|
||||
ret.Checksum = s.Checksum
|
||||
|
||||
if s.FileModTime.Valid {
|
||||
ret.FileModTime = s.FileModTime.Timestamp
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *Gallery) SetFile(f File) {
|
||||
path := f.Path
|
||||
s.Path = sql.NullString{
|
||||
String: path,
|
||||
Valid: true,
|
||||
}
|
||||
|
||||
if f.Checksum != "" {
|
||||
s.Checksum = f.Checksum
|
||||
}
|
||||
|
||||
zeroTime := time.Time{}
|
||||
if f.FileModTime != zeroTime {
|
||||
s.FileModTime = NullSQLiteTimestamp{
|
||||
Timestamp: f.FileModTime,
|
||||
Valid: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetTitle returns the title of the scene. If the Title field is empty,
|
||||
// then the base filename is returned.
|
||||
func (s Gallery) GetTitle() string {
|
||||
|
||||
Reference in New Issue
Block a user