mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01: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:
parent
dc934d73fa
commit
967a25f64a
6 changed files with 31 additions and 14 deletions
|
|
@ -58,9 +58,16 @@ func (r *mutationResolver) SubmitStashBoxSceneDraft(ctx context.Context, input S
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
filepath := manager.GetInstance().Paths.Scene.GetScreenshotPath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
|
if scene == nil {
|
||||||
|
return fmt.Errorf("scene with id %d not found", id)
|
||||||
|
}
|
||||||
|
|
||||||
res, err = client.SubmitSceneDraft(ctx, scene, boxes[input.StashBoxIndex].Endpoint, filepath)
|
cover, err := r.sceneService.GetCover(ctx, scene)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("getting scene cover: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err = client.SubmitSceneDraft(ctx, scene, boxes[input.StashBoxIndex].Endpoint, cover)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ type SceneService interface {
|
||||||
AssignFile(ctx context.Context, sceneID int, fileID file.ID) error
|
AssignFile(ctx context.Context, sceneID int, fileID file.ID) error
|
||||||
Merge(ctx context.Context, sourceIDs []int, destinationID int, values models.ScenePartial) error
|
Merge(ctx context.Context, sourceIDs []int, destinationID int, values models.ScenePartial) error
|
||||||
Destroy(ctx context.Context, scene *models.Scene, fileDeleter *scene.FileDeleter, deleteGenerated, deleteFile bool) error
|
Destroy(ctx context.Context, scene *models.Scene, fileDeleter *scene.FileDeleter, deleteGenerated, deleteFile bool) error
|
||||||
|
|
||||||
|
GetCover(ctx context.Context, scene *models.Scene) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageService interface {
|
type ImageService interface {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/file"
|
"github.com/stashapp/stash/pkg/file"
|
||||||
|
"github.com/stashapp/stash/pkg/fsutil"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/models/paths"
|
"github.com/stashapp/stash/pkg/models/paths"
|
||||||
|
|
||||||
|
|
@ -86,3 +87,17 @@ func SetScreenshot(paths *paths.Paths, checksum string, imageData []byte) error
|
||||||
|
|
||||||
return err
|
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"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
|
@ -20,7 +19,6 @@ import (
|
||||||
|
|
||||||
"github.com/Yamashou/gqlgenc/graphqljson"
|
"github.com/Yamashou/gqlgenc/graphqljson"
|
||||||
"github.com/stashapp/stash/pkg/file"
|
"github.com/stashapp/stash/pkg/file"
|
||||||
"github.com/stashapp/stash/pkg/fsutil"
|
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/match"
|
"github.com/stashapp/stash/pkg/match"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
|
|
@ -804,7 +802,7 @@ func appendFingerprintUnique(v []*graphql.FingerprintInput, toAdd *graphql.Finge
|
||||||
return append(v, toAdd)
|
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{}
|
draft := graphql.SceneDraftInput{}
|
||||||
var image io.Reader
|
var image io.Reader
|
||||||
r := c.repository
|
r := c.repository
|
||||||
|
|
@ -934,14 +932,8 @@ func (c Client) SubmitSceneDraft(ctx context.Context, scene *models.Scene, endpo
|
||||||
}
|
}
|
||||||
draft.Tags = tags
|
draft.Tags = tags
|
||||||
|
|
||||||
if imagePath != "" {
|
if cover != nil {
|
||||||
exists, _ := fsutil.FileExists(imagePath)
|
image = bytes.NewReader(cover)
|
||||||
if exists {
|
|
||||||
file, err := os.Open(imagePath)
|
|
||||||
if err == nil {
|
|
||||||
image = file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := scene.LoadStashIDs(ctx, r.Scene); err != nil {
|
if err := scene.LoadStashIDs(ctx, r.Scene); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ export const SubmitStashBoxDraft: React.FC<IProps> = ({
|
||||||
<Form.Control
|
<Form.Control
|
||||||
as="select"
|
as="select"
|
||||||
onChange={handleSelectBox}
|
onChange={handleSelectBox}
|
||||||
className="col-6"
|
className="col-6 input-control"
|
||||||
>
|
>
|
||||||
{boxes.map((box, i) => (
|
{boxes.map((box, i) => (
|
||||||
<option value={i} key={`${box.endpoint}-${i}`}>
|
<option value={i} key={`${box.endpoint}-${i}`}>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
* Overhauled and improved HLS streaming. ([#3274](https://github.com/stashapp/stash/pull/3274))
|
* Overhauled and improved HLS streaming. ([#3274](https://github.com/stashapp/stash/pull/3274))
|
||||||
|
|
||||||
### 🐛 Bug fixes
|
### 🐛 Bug fixes
|
||||||
|
* Fixed scene cover not being included when submitting file-less scenes to stash-box. ([#3465](https://github.com/stashapp/stash/pull/3465))
|
||||||
* Fixed URL not being during stash-box scrape if the Studio URL is not set. ([#3439](https://github.com/stashapp/stash/pull/3439))
|
* Fixed URL not being during stash-box scrape if the Studio URL is not set. ([#3439](https://github.com/stashapp/stash/pull/3439))
|
||||||
* Fixed generating previews for variable frame rate videos. ([#3376](https://github.com/stashapp/stash/pull/3376))
|
* Fixed generating previews for variable frame rate videos. ([#3376](https://github.com/stashapp/stash/pull/3376))
|
||||||
* Fixed errors reading zip files with non-UTF8 encoding. ([#3389](https://github.com/stashapp/stash/pull/3389))
|
* Fixed errors reading zip files with non-UTF8 encoding. ([#3389](https://github.com/stashapp/stash/pull/3389))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue