diff --git a/pkg/api/resolver_query_logs.go b/pkg/api/resolver_query_logs.go index 2fc0fa36f23..2373205c4e2 100644 --- a/pkg/api/resolver_query_logs.go +++ b/pkg/api/resolver_query_logs.go @@ -20,4 +20,4 @@ func (r *queryResolver) Logs(ctx context.Context) ([]*models.LogEntry, error) { } return ret, nil -} \ No newline at end of file +} diff --git a/pkg/api/routes_gallery.go b/pkg/api/routes_gallery.go index 54784fd81f2..0c53cf35c87 100644 --- a/pkg/api/routes_gallery.go +++ b/pkg/api/routes_gallery.go @@ -27,9 +27,16 @@ func (rs galleryRoutes) File(w http.ResponseWriter, r *http.Request) { thumb := r.URL.Query().Get("thumb") w.Header().Add("Cache-Control", "max-age=604800000") // 1 Week if thumb == "true" { - _, _ = w.Write(gallery.GetThumbnail(fileIndex)) - } else { + _, _ = w.Write(gallery.GetThumbnail(fileIndex, 200)) + } else if thumb == "" { _, _ = w.Write(gallery.GetImage(fileIndex)) + } else { + width, err := strconv.ParseInt(thumb, 0, 64) + if err != nil { + http.Error(w, http.StatusText(400), 400) + return + } + _, _ = w.Write(gallery.GetThumbnail(fileIndex, int(width))) } } diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index c0c721bd2f1..648fdd2f99c 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -28,6 +28,7 @@ var once sync.Once type flagStruct struct { configFilePath string } + var flags = flagStruct{} func GetInstance() *singleton { diff --git a/pkg/manager/running_streams.go b/pkg/manager/running_streams.go index c8787387b0c..6cccb733a38 100644 --- a/pkg/manager/running_streams.go +++ b/pkg/manager/running_streams.go @@ -9,7 +9,7 @@ import ( ) var ( - streamingFiles = make(map[string][]*http.ResponseWriter) + streamingFiles = make(map[string][]*http.ResponseWriter) streamingFilesMutex = sync.RWMutex{} ) diff --git a/pkg/manager/scene.go b/pkg/manager/scene.go index e222f50c4e3..1bca4568f30 100644 --- a/pkg/manager/scene.go +++ b/pkg/manager/scene.go @@ -6,16 +6,16 @@ import ( "strconv" "github.com/jmoiron/sqlx" - + "github.com/stashapp/stash/pkg/logger" "github.com/stashapp/stash/pkg/models" "github.com/stashapp/stash/pkg/utils" ) -func DestroyScene(sceneID int, tx *sqlx.Tx) (error) { +func DestroyScene(sceneID int, tx *sqlx.Tx) error { qb := models.NewSceneQueryBuilder() jqb := models.NewJoinsQueryBuilder() - + _, err := qb.Find(sceneID) if err != nil { return err @@ -40,7 +40,7 @@ func DestroyScene(sceneID int, tx *sqlx.Tx) (error) { if err := qb.Destroy(strconv.Itoa(sceneID), tx); err != nil { return err } - + return nil } @@ -130,4 +130,4 @@ func DeleteSceneFile(scene *models.Scene) { if err != nil { logger.Warnf("Could not delete file %s: %s", scene.Path, err.Error()) } -} \ No newline at end of file +} diff --git a/pkg/manager/task_autotag_test.go b/pkg/manager/task_autotag_test.go index 3c15e436f33..05221e39915 100644 --- a/pkg/manager/task_autotag_test.go +++ b/pkg/manager/task_autotag_test.go @@ -26,6 +26,7 @@ const testExtension = ".mp4" const existingStudioName = "ExistingStudio" const existingStudioSceneName = testName + ".dontChangeStudio" + testExtension + var existingStudioID int var testSeparators = []string{ diff --git a/pkg/models/model_gallery.go b/pkg/models/model_gallery.go index 5573c7917f6..53ab2b4061c 100644 --- a/pkg/models/model_gallery.go +++ b/pkg/models/model_gallery.go @@ -52,13 +52,13 @@ func (g *Gallery) GetImage(index int) []byte { return data } -func (g *Gallery) GetThumbnail(index int) []byte { +func (g *Gallery) GetThumbnail(index int, width int) []byte { data, _ := g.readZipFile(index) srcImage, _, err := image.Decode(bytes.NewReader(data)) if err != nil { return data } - resizedImage := imaging.Resize(srcImage, 100, 0, imaging.NearestNeighbor) + resizedImage := imaging.Resize(srcImage, width, 0, imaging.Box) buf := new(bytes.Buffer) err = jpeg.Encode(buf, resizedImage, nil) if err != nil { diff --git a/pkg/models/querybuilder_scene_marker.go b/pkg/models/querybuilder_scene_marker.go index 1460d0dde50..5e0b683dbea 100644 --- a/pkg/models/querybuilder_scene_marker.go +++ b/pkg/models/querybuilder_scene_marker.go @@ -162,8 +162,8 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp havingClauses = append(havingClauses, "((COUNT(DISTINCT ptj.id) + COUNT(DISTINCT tj.tag_id)) >= "+strconv.Itoa(requiredCount)+")") } else if tagsFilter.Modifier == CriterionModifierExcludes { // excludes all of the provided ids - whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in " + getInBinding(length)) - whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in " + getInBinding(length) + ")") + whereClauses = append(whereClauses, "scene_markers.primary_tag_id not in "+getInBinding(length)) + whereClauses = append(whereClauses, "not exists (select smt.scene_marker_id from scene_markers_tags as smt where smt.scene_marker_id = scene_markers.id and smt.tag_id in "+getInBinding(length)+")") } for _, tagID := range tagsFilter.Value { @@ -176,7 +176,7 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp if sceneTagsFilter := sceneMarkerFilter.SceneTags; sceneTagsFilter != nil && len(sceneTagsFilter.Value) > 0 { length := len(sceneTagsFilter.Value) - + if sceneTagsFilter.Modifier == CriterionModifierIncludes || sceneTagsFilter.Modifier == CriterionModifierIncludesAll { body += " LEFT JOIN scenes_tags AS scene_tags_join ON scene_tags_join.scene_id = scene.id AND scene_tags_join.tag_id IN " + getInBinding(length) @@ -191,9 +191,9 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp havingClauses = append(havingClauses, "COUNT(DISTINCT scene_tags_join.tag_id) >= "+strconv.Itoa(requiredCount)) } else if sceneTagsFilter.Modifier == CriterionModifierExcludes { // excludes all of the provided ids - whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN " + getInBinding(length) + ")") + whereClauses = append(whereClauses, "not exists (select st.scene_id from scenes_tags as st where st.scene_id = scene.id AND st.tag_id IN "+getInBinding(length)+")") } - + for _, tagID := range sceneTagsFilter.Value { args = append(args, tagID) } @@ -213,13 +213,13 @@ func (qb *SceneMarkerQueryBuilder) Query(sceneMarkerFilter *SceneMarkerFilterTyp if performersFilter.Modifier == CriterionModifierIncludesAll { requiredCount = length } - + havingClauses = append(havingClauses, "COUNT(DISTINCT scene_performers.performer_id) >= "+strconv.Itoa(requiredCount)) } else if performersFilter.Modifier == CriterionModifierExcludes { // excludes all of the provided ids - whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN " + getInBinding(length) + ")") + whereClauses = append(whereClauses, "not exists (select sp.scene_id from performers_scenes as sp where sp.scene_id = scene.id AND sp.performer_id IN "+getInBinding(length)+")") } - + for _, performerID := range performersFilter.Value { args = append(args, performerID) } diff --git a/pkg/utils/resources.go b/pkg/utils/resources.go index 3bc70cd7354..89cbabe3d10 100644 --- a/pkg/utils/resources.go +++ b/pkg/utils/resources.go @@ -1,3 +1,3 @@ package utils -var PendingGenerateResource, _ = GetDataFromBase64String("iVBORw0KGgoAAAANSUhEUgAAAfQAAADwBAMAAAAEHosbAAAAG1BMVEUAAADMzMyZmZkzMzNmZmZ/f38ZGRmysrJMTEwh+DPkAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEOklEQVR4nO3YzW/bNhjHcfpN9jGP8iIfI2xrdrQLrLs67Zpdo21pelTWdbnGSTPvaBdosT+7z8OXxAFkIDu0Vrfv59AmpEjoJ1IkFecAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC/JCqfNNV0Dja1GR0Vv36+O/piLLrsNdVo9EyaKnpzbfLkMZ1vfnptIGdnZ6XUDTUbo0+lOJKiqUlDFy1mqbP5aUPNpujZfK92b6WpSUMXLeYHfHXVULPpvvtiS0P1mFRfQfSLnYaaTffd8SvDsHF9eGQX7eCj2y2+n79z9hCeFq/0/7fzJ2HCp4LsPJ+EJWHln1P/1vml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uJB9M56dBv1eG01s3/tOdiMWVzfRY9d2FWXkr8O73oqbaEYvRsPZzGplT4YdXvX46iHU+8ovuvOpeipC7uquvFdpXe9nWL0gW29b+qU1Ja56Xr0gSbohWtt4QvLvR1usmcpeurCrrKXIox6Km2hGL2v27eNYkxqk/p4PbrVD8K1A/+9apu87tw2qjF66sIvevrojndSw7VTUJvE6OHkMUlJp3ouna9Ht/ppuDaTGzvI2fnHjjS7KXrqwo/6TOfIji2OqbSF0kGrysNBNr7a+eSprEfX+pcSr13J7S8yLmudBt+Gg2zoJ3bh3/X9fyr9rB/mH1NpC6Xo3fj5EgdZt+wHE97q9+K1I9uullXtTzb53TKXuggrvBSXMhvo50u3rXvbXXT3vvje3UXXj9a/H2xuzv1cfEzX/jEvTtxKfxmV18v76LGLsK8Xs95imZU3qfTr1vyXuv+83gsd42Lbd7EVI/tyy7d9F1uRyateOd72XWyHfaY2/d32f8C2q1YeTD6/7Pn1ybbvAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAL+ITrOa6fKadMcEAAAAASUVORK5CYII=") diff --git a/tools.go b/tools.go index b57bc6d009e..09a5657f4d8 100644 --- a/tools.go +++ b/tools.go @@ -4,4 +4,4 @@ package main import ( _ "github.com/99designs/gqlgen" -) \ No newline at end of file +)