Create missing covers during scan (#2995)

* Create missing covers during scan
* Update changelog and release notes
This commit is contained in:
WithoutPants
2022-10-11 14:22:23 +11:00
committed by GitHub
parent e3cd36f25f
commit 6b5d5cc628
4 changed files with 47 additions and 10 deletions

View File

@@ -103,14 +103,21 @@ type galleryFinder interface {
FindByFolderID(ctx context.Context, folderID file.FolderID) ([]*models.Gallery, error)
}
type sceneFinder interface {
fileCounter
FindByPrimaryFileID(ctx context.Context, fileID file.ID) ([]*models.Scene, error)
}
// handlerRequiredFilter returns true if a File's handler needs to be executed despite the file not being updated.
type handlerRequiredFilter struct {
extensionConfig
SceneFinder fileCounter
SceneFinder sceneFinder
ImageFinder fileCounter
GalleryFinder galleryFinder
FolderCache *lru.LRU
videoFileNamingAlgorithm models.HashAlgorithm
}
func newHandlerRequiredFilter(c *config.Instance) *handlerRequiredFilter {
@@ -118,11 +125,12 @@ func newHandlerRequiredFilter(c *config.Instance) *handlerRequiredFilter {
processes := c.GetParallelTasksWithAutoDetection()
return &handlerRequiredFilter{
extensionConfig: newExtensionConfig(c),
SceneFinder: db.Scene,
ImageFinder: db.Image,
GalleryFinder: db.Gallery,
FolderCache: lru.New(processes * 2),
extensionConfig: newExtensionConfig(c),
SceneFinder: db.Scene,
ImageFinder: db.Image,
GalleryFinder: db.Gallery,
FolderCache: lru.New(processes * 2),
videoFileNamingAlgorithm: c.GetVideoFileNamingAlgorithm(),
}
}
@@ -180,6 +188,25 @@ func (f *handlerRequiredFilter) Accept(ctx context.Context, ff file.File) bool {
}
}
if isVideoFile {
// check if the screenshot file exists
hash := scene.GetHash(ff, f.videoFileNamingAlgorithm)
ssPath := instance.Paths.Scene.GetScreenshotPath(hash)
if exists, _ := fsutil.FileExists(ssPath); !exists {
// if not, check if the file is a primary file for a scene
scenes, err := f.SceneFinder.FindByPrimaryFileID(ctx, ff.Base().ID)
if err != nil {
// just ignore
return false
}
if len(scenes) > 0 {
// if it is, then it needs to be re-generated
return true
}
}
}
return false
}

View File

@@ -489,6 +489,20 @@ func (qb *SceneStore) FindByFileID(ctx context.Context, fileID file.ID) ([]*mode
return ret, nil
}
func (qb *SceneStore) FindByPrimaryFileID(ctx context.Context, fileID file.ID) ([]*models.Scene, error) {
sq := dialect.From(scenesFilesJoinTable).Select(scenesFilesJoinTable.Col(sceneIDColumn)).Where(
scenesFilesJoinTable.Col(fileIDColumn).Eq(fileID),
scenesFilesJoinTable.Col("primary").Eq(1),
)
ret, err := qb.findBySubquery(ctx, sq)
if err != nil {
return nil, fmt.Errorf("getting scenes by primary file id %d: %w", fileID, err)
}
return ret, nil
}
func (qb *SceneStore) CountByFileID(ctx context.Context, fileID file.ID) (int, error) {
joinTable := scenesFilesJoinTable

View File

@@ -1,7 +1,6 @@
After migrating, please run a scan on your entire library to populate missing data, and to ingest identical files which were previously ignored.
### 💥 Known issues and other changes
* Missing covers are not currently regenerated.
* Import/export schema has changed and is incompatible with the previous version.
### ✨ New Features

View File

@@ -1,8 +1,5 @@
After migrating, please run a scan on your entire library to populate missing data, and to ingest identical files which were previously ignored.
### 💥 Known issues
* Missing covers are not currently regenerated. Need to consider further, especially around scene cover redesign.
### Other changes:
* Import/export schema has changed and is incompatible with the previous version.
* Changelog has been moved from the stats page to a section in the Settings page.