mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 08:54:10 +01:00
* Move main to cmd * Move api to internal * Move logger and manager to internal * Move shell hiding code to separate package * Decouple job from desktop and utils * Decouple session from config * Move static into internal * Decouple config from dlna * Move desktop to internal * Move dlna to internal * Decouple remaining packages from config * Move config into internal * Move jsonschema and paths to models * Make ffmpeg functions private * Move file utility methods into fsutil package * Move symwalk into fsutil * Move single-use util functions into client package * Move slice functions to separate packages * Add env var to suppress windowsgui arg * Move hash functions into separate package * Move identify to internal * Move autotag to internal * Touch UI when generating backend
59 lines
1.4 KiB
Go
59 lines
1.4 KiB
Go
package manager
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/stashapp/stash/pkg/file"
|
|
"github.com/stashapp/stash/pkg/logger"
|
|
"github.com/stashapp/stash/pkg/models"
|
|
"github.com/stashapp/stash/pkg/scene"
|
|
)
|
|
|
|
func (t *ScanTask) scanScene() *models.Scene {
|
|
logError := func(err error) *models.Scene {
|
|
logger.Error(err.Error())
|
|
return nil
|
|
}
|
|
|
|
var retScene *models.Scene
|
|
var s *models.Scene
|
|
|
|
if err := t.TxnManager.WithReadTxn(context.TODO(), func(r models.ReaderRepository) error {
|
|
var err error
|
|
s, err = r.Scene().FindByPath(t.file.Path())
|
|
return err
|
|
}); err != nil {
|
|
logger.Error(err.Error())
|
|
return nil
|
|
}
|
|
|
|
scanner := scene.Scanner{
|
|
Scanner: scene.FileScanner(&file.FSHasher{}, t.fileNamingAlgorithm, t.calculateMD5),
|
|
StripFileExtension: t.StripFileExtension,
|
|
FileNamingAlgorithm: t.fileNamingAlgorithm,
|
|
Ctx: t.ctx,
|
|
TxnManager: t.TxnManager,
|
|
Paths: GetInstance().Paths,
|
|
Screenshotter: &instance.FFMPEG,
|
|
VideoFileCreator: &instance.FFProbe,
|
|
PluginCache: instance.PluginCache,
|
|
MutexManager: t.mutexManager,
|
|
UseFileMetadata: t.UseFileMetadata,
|
|
}
|
|
|
|
if s != nil {
|
|
if err := scanner.ScanExisting(s, t.file); err != nil {
|
|
return logError(err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
var err error
|
|
retScene, err = scanner.ScanNew(t.file)
|
|
if err != nil {
|
|
return logError(err)
|
|
}
|
|
|
|
return retScene
|
|
}
|