mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Cleanup fixes (#1422)
* cleanup: remove dead code removing some code that does nothing * cleanup: fixing usage of deprecated gqlgen/graphql api in api/changeset_translator * cleanup: changing to recommended comparison methods Changing byte and case-insensitive string comparison to the recommended methods. * cleanup: making staticcheck happy
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
|||||||
const updateInputField = "input"
|
const updateInputField = "input"
|
||||||
|
|
||||||
func getArgumentMap(ctx context.Context) map[string]interface{} {
|
func getArgumentMap(ctx context.Context) map[string]interface{} {
|
||||||
rctx := graphql.GetResolverContext(ctx)
|
rctx := graphql.GetFieldContext(ctx)
|
||||||
reqCtx := graphql.GetRequestContext(ctx)
|
reqCtx := graphql.GetOperationContext(ctx)
|
||||||
return rctx.Field.ArgumentMap(reqCtx.Variables)
|
return rctx.Field.ArgumentMap(reqCtx.Variables)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,13 +208,10 @@ func (r *queryResolver) SceneMarkerTags(ctx context.Context, scene_id string) ([
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, hasKey := tags[markerPrimaryTag.ID]
|
_, hasKey := tags[markerPrimaryTag.ID]
|
||||||
var sceneMarkerTag *models.SceneMarkerTag
|
|
||||||
if !hasKey {
|
if !hasKey {
|
||||||
sceneMarkerTag = &models.SceneMarkerTag{Tag: markerPrimaryTag}
|
sceneMarkerTag := &models.SceneMarkerTag{Tag: markerPrimaryTag}
|
||||||
tags[markerPrimaryTag.ID] = sceneMarkerTag
|
tags[markerPrimaryTag.ID] = sceneMarkerTag
|
||||||
keys = append(keys, markerPrimaryTag.ID)
|
keys = append(keys, markerPrimaryTag.ID)
|
||||||
} else {
|
|
||||||
sceneMarkerTag = tags[markerPrimaryTag.ID]
|
|
||||||
}
|
}
|
||||||
tags[markerPrimaryTag.ID].SceneMarkers = append(tags[markerPrimaryTag.ID].SceneMarkers, sceneMarker)
|
tags[markerPrimaryTag.ID].SceneMarkers = append(tags[markerPrimaryTag.ID].SceneMarkers, sceneMarker)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ func (r *sceneResolver) Movies(ctx context.Context, obj *models.Scene) (ret []*m
|
|||||||
}
|
}
|
||||||
|
|
||||||
if sceneIdx.Valid {
|
if sceneIdx.Valid {
|
||||||
var idx int
|
idx := int(sceneIdx.Int64)
|
||||||
idx = int(sceneIdx.Int64)
|
|
||||||
sceneMovie.SceneIndex = &idx
|
sceneMovie.SceneIndex = &idx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func matchFileSimple(file string, regExps []*regexp.Regexp) bool {
|
|||||||
func matchExtension(path string, extensions []string) bool {
|
func matchExtension(path string, extensions []string) bool {
|
||||||
ext := filepath.Ext(path)
|
ext := filepath.Ext(path)
|
||||||
for _, e := range extensions {
|
for _, e := range extensions {
|
||||||
if strings.ToLower(ext) == strings.ToLower("."+e) {
|
if strings.EqualFold(ext, "."+e) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ var nilTime = (time.Time{}).UnixNano()
|
|||||||
func CompareJSON(a interface{}, b interface{}) bool {
|
func CompareJSON(a interface{}, b interface{}) bool {
|
||||||
aBuf, _ := encode(a)
|
aBuf, _ := encode(a)
|
||||||
bBuf, _ := encode(b)
|
bBuf, _ := encode(b)
|
||||||
return bytes.Compare(aBuf, bBuf) == 0
|
return bytes.Equal(aBuf, bBuf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalToFile(filePath string, j interface{}) error {
|
func marshalToFile(filePath string, j interface{}) error {
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ func (t *GenerateTranscodeTask) Start(wg *sizedwaitgroup.SizedWaitGroup) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Debugf("[transcode] <%s> created transcode: %s", sceneHash, outputPath)
|
logger.Debugf("[transcode] <%s> created transcode: %s", sceneHash, outputPath)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if transcode is needed
|
// return true if transcode is needed
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import (
|
|||||||
func setCookies(jar *cookiejar.Jar, scraperConfig config) {
|
func setCookies(jar *cookiejar.Jar, scraperConfig config) {
|
||||||
driverOptions := scraperConfig.DriverOptions
|
driverOptions := scraperConfig.DriverOptions
|
||||||
if driverOptions != nil && !driverOptions.UseCDP {
|
if driverOptions != nil && !driverOptions.UseCDP {
|
||||||
var foundURLs []*url.URL
|
|
||||||
|
|
||||||
for _, ckURL := range driverOptions.Cookies { // go through all cookies
|
for _, ckURL := range driverOptions.Cookies { // go through all cookies
|
||||||
url, err := url.Parse(ckURL.CookieURL) // CookieURL must be valid, include schema
|
url, err := url.Parse(ckURL.CookieURL) // CookieURL must be valid, include schema
|
||||||
@@ -44,12 +43,8 @@ func setCookies(jar *cookiejar.Jar, scraperConfig config) {
|
|||||||
|
|
||||||
if jar.Cookies(url) == nil {
|
if jar.Cookies(url) == nil {
|
||||||
logger.Warnf("Setting jar cookies for %s failed", url.String())
|
logger.Warnf("Setting jar cookies for %s failed", url.String())
|
||||||
} else {
|
|
||||||
|
|
||||||
foundURLs = append(foundURLs, url)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -659,13 +659,7 @@ func (c mappedScraperAttrConfig) hasSplit() bool {
|
|||||||
|
|
||||||
func (c mappedScraperAttrConfig) concatenateResults(nodes []string) string {
|
func (c mappedScraperAttrConfig) concatenateResults(nodes []string) string {
|
||||||
separator := c.Concat
|
separator := c.Concat
|
||||||
result := []string{}
|
return strings.Join(nodes, separator)
|
||||||
|
|
||||||
for _, text := range nodes {
|
|
||||||
result = append(result, text)
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(result, separator)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c mappedScraperAttrConfig) cleanResults(nodes []string) []string {
|
func (c mappedScraperAttrConfig) cleanResults(nodes []string) []string {
|
||||||
|
|||||||
@@ -573,7 +573,7 @@ func (c Client) FindStashBoxPerformerByName(name string) (*models.ScrapedScenePe
|
|||||||
|
|
||||||
var ret *models.ScrapedScenePerformer
|
var ret *models.ScrapedScenePerformer
|
||||||
for _, performer := range performers.SearchPerformer {
|
for _, performer := range performers.SearchPerformer {
|
||||||
if strings.ToLower(performer.Name) == strings.ToLower(name) {
|
if strings.EqualFold(performer.Name, name) {
|
||||||
ret = performerFragmentToScrapedScenePerformer(*performer)
|
ret = performerFragmentToScrapedScenePerformer(*performer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user