mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Include database cover in draft submission if filesystem version not present (#3465)
* Fix styling of stash-box dropdown * Use cover blob in draft submission if present
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/fsutil"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/paths"
|
||||
|
||||
@@ -86,3 +87,17 @@ func SetScreenshot(paths *paths.Paths, checksum string, imageData []byte) error
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Service) GetCover(ctx context.Context, scene *models.Scene) ([]byte, error) {
|
||||
if scene.Path != "" {
|
||||
filepath := s.Paths.Scene.GetScreenshotPath(scene.GetHash(s.Config.GetVideoFileNamingAlgorithm()))
|
||||
|
||||
// fall back to the scene image blob if the file isn't present
|
||||
screenshotExists, _ := fsutil.FileExists(filepath)
|
||||
if screenshotExists {
|
||||
return os.ReadFile(filepath)
|
||||
}
|
||||
}
|
||||
|
||||
return s.Repository.GetCover(ctx, scene.ID)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -20,7 +19,6 @@ import (
|
||||
|
||||
"github.com/Yamashou/gqlgenc/graphqljson"
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/fsutil"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/match"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
@@ -804,7 +802,7 @@ func appendFingerprintUnique(v []*graphql.FingerprintInput, toAdd *graphql.Finge
|
||||
return append(v, toAdd)
|
||||
}
|
||||
|
||||
func (c Client) SubmitSceneDraft(ctx context.Context, scene *models.Scene, endpoint string, imagePath string) (*string, error) {
|
||||
func (c Client) SubmitSceneDraft(ctx context.Context, scene *models.Scene, endpoint string, cover []byte) (*string, error) {
|
||||
draft := graphql.SceneDraftInput{}
|
||||
var image io.Reader
|
||||
r := c.repository
|
||||
@@ -934,14 +932,8 @@ func (c Client) SubmitSceneDraft(ctx context.Context, scene *models.Scene, endpo
|
||||
}
|
||||
draft.Tags = tags
|
||||
|
||||
if imagePath != "" {
|
||||
exists, _ := fsutil.FileExists(imagePath)
|
||||
if exists {
|
||||
file, err := os.Open(imagePath)
|
||||
if err == nil {
|
||||
image = file
|
||||
}
|
||||
}
|
||||
if cover != nil {
|
||||
image = bytes.NewReader(cover)
|
||||
}
|
||||
|
||||
if err := scene.LoadStashIDs(ctx, r.Scene); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user