mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Remove unused (#1709)
* Remove stuff which isn't being used Some fields, functions and structs aren't in use by the project. Remove them for janitorial reasons. * Remove more unused code All of these functions are currently not in use. Clean up the code by removal, since the version control has the code if need be. * Remove unused functions There's a large set of unused functions and variables in the code base. Remove these, so it clearer what code to support going forward. Dead code has been eliminated. Where applicable, comment const-sections in tests, so reserved identifiers are still known. * Fix use-def of tsURL The first def of tsURL doesn't matter because there's no use before we hit the 2nd def. * Remove dead code assignment Setting logFile = "" is effectively dead code, because there's no use of it later. * Comment out found The variable 'found' is dead in the function (because no post-process action is following it). Comment it for now. * Comment dead code in tests These might provide hints as to what isn't covered at the moment. * Dead code removal In the case of constants where iota is involved, move the iota so it matches the current key values. This avoids problems with persistently stored key IDs.
This commit is contained in:
@@ -5,8 +5,8 @@ package api
|
|||||||
type key int
|
type key int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
galleryKey key = iota
|
// galleryKey key = 0
|
||||||
performerKey
|
performerKey key = iota + 1
|
||||||
sceneKey
|
sceneKey
|
||||||
studioKey
|
studioKey
|
||||||
movieKey
|
movieKey
|
||||||
|
|||||||
@@ -2,32 +2,12 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/stashapp/stash/pkg/job"
|
"github.com/stashapp/stash/pkg/job"
|
||||||
"github.com/stashapp/stash/pkg/manager"
|
"github.com/stashapp/stash/pkg/manager"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
type throttledUpdate struct {
|
|
||||||
id int
|
|
||||||
pendingUpdate *job.Job
|
|
||||||
lastUpdate time.Time
|
|
||||||
broadcastTimer *time.Timer
|
|
||||||
killTimer *time.Timer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tu *throttledUpdate) broadcast(output chan *models.JobStatusUpdate) {
|
|
||||||
tu.lastUpdate = time.Now()
|
|
||||||
output <- &models.JobStatusUpdate{
|
|
||||||
Type: models.JobStatusUpdateTypeUpdate,
|
|
||||||
Job: jobToJobModel(*tu.pendingUpdate),
|
|
||||||
}
|
|
||||||
|
|
||||||
tu.broadcastTimer = nil
|
|
||||||
tu.pendingUpdate = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeJobStatusUpdate(t models.JobStatusUpdateType, j job.Job) *models.JobStatusUpdate {
|
func makeJobStatusUpdate(t models.JobStatusUpdateType, j job.Job) *models.JobStatusUpdate {
|
||||||
return &models.JobStatusUpdate{
|
return &models.JobStatusUpdate{
|
||||||
Type: t,
|
Type: t,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import (
|
|||||||
|
|
||||||
type sceneRoutes struct {
|
type sceneRoutes struct {
|
||||||
txnManager models.TransactionManager
|
txnManager models.TransactionManager
|
||||||
sceneServer manager.SceneServer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs sceneRoutes) Routes() chi.Router {
|
func (rs sceneRoutes) Routes() chi.Router {
|
||||||
|
|||||||
@@ -98,16 +98,6 @@ func authenticateHandler() func(http.Handler) http.Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func visitedPluginHandler() func(http.Handler) http.Handler {
|
|
||||||
return func(next http.Handler) http.Handler {
|
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
// get the visited plugins and set them in the context
|
|
||||||
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const loginEndPoint = "/login"
|
const loginEndPoint = "/login"
|
||||||
|
|
||||||
func Start() {
|
func Start() {
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ import (
|
|||||||
"github.com/stashapp/stash/pkg/session"
|
"github.com/stashapp/stash/pkg/session"
|
||||||
)
|
)
|
||||||
|
|
||||||
const cookieName = "session"
|
|
||||||
const usernameFormKey = "username"
|
|
||||||
const passwordFormKey = "password"
|
|
||||||
const userIDKey = "userID"
|
|
||||||
|
|
||||||
const returnURLParam = "returnURL"
|
const returnURLParam = "returnURL"
|
||||||
|
|
||||||
type loginTemplateData struct {
|
type loginTemplateData struct {
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ const (
|
|||||||
resPath = "/res"
|
resPath = "/res"
|
||||||
iconPath = "/icon"
|
iconPath = "/icon"
|
||||||
rootDescPath = "/rootDesc.xml"
|
rootDescPath = "/rootDesc.xml"
|
||||||
contentDirectorySCPDURL = "/scpd/ContentDirectory.xml"
|
|
||||||
contentDirectoryEventSubURL = "/evt/ContentDirectory"
|
contentDirectoryEventSubURL = "/evt/ContentDirectory"
|
||||||
serviceControlURL = "/ctl"
|
serviceControlURL = "/ctl"
|
||||||
deviceIconPath = "/deviceIcon"
|
deviceIconPath = "/deviceIcon"
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ func WriteHLSPlaylist(probeResult VideoFile, baseUrl string, w io.Writer) {
|
|||||||
leftover := duration
|
leftover := duration
|
||||||
upTo := 0.0
|
upTo := 0.0
|
||||||
|
|
||||||
tsURL := baseUrl
|
|
||||||
i := strings.LastIndex(baseUrl, ".m3u8")
|
i := strings.LastIndex(baseUrl, ".m3u8")
|
||||||
tsURL = baseUrl[0:i] + ".ts"
|
tsURL := baseUrl[0:i] + ".ts"
|
||||||
|
|
||||||
for leftover > 0 {
|
for leftover > 0 {
|
||||||
thisLength := hlsSegmentLength
|
thisLength := hlsSegmentLength
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const (
|
|||||||
missingStudioID = 5
|
missingStudioID = 5
|
||||||
errStudioID = 6
|
errStudioID = 6
|
||||||
|
|
||||||
noTagsID = 11
|
// noTagsID = 11
|
||||||
errTagsID = 12
|
errTagsID = 12
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,11 +39,6 @@ const (
|
|||||||
studioName = "studioName"
|
studioName = "studioName"
|
||||||
)
|
)
|
||||||
|
|
||||||
var names = []string{
|
|
||||||
"name1",
|
|
||||||
"name2",
|
|
||||||
}
|
|
||||||
|
|
||||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
@@ -71,18 +66,6 @@ func createFullGallery(id int) models.Gallery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyGallery(id int) models.Gallery {
|
|
||||||
return models.Gallery{
|
|
||||||
ID: id,
|
|
||||||
CreatedAt: models.SQLiteTimestamp{
|
|
||||||
Timestamp: createTime,
|
|
||||||
},
|
|
||||||
UpdatedAt: models.SQLiteTimestamp{
|
|
||||||
Timestamp: updateTime,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func createFullJSONGallery() *jsonschema.Gallery {
|
func createFullJSONGallery() *jsonschema.Gallery {
|
||||||
return &jsonschema.Gallery{
|
return &jsonschema.Gallery{
|
||||||
Title: title,
|
Title: title,
|
||||||
@@ -103,17 +86,6 @@ func createFullJSONGallery() *jsonschema.Gallery {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyJSONGallery() *jsonschema.Gallery {
|
|
||||||
return &jsonschema.Gallery{
|
|
||||||
CreatedAt: models.JSONTime{
|
|
||||||
Time: createTime,
|
|
||||||
},
|
|
||||||
UpdatedAt: models.JSONTime{
|
|
||||||
Time: updateTime,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type basicTestScenario struct {
|
type basicTestScenario struct {
|
||||||
input models.Gallery
|
input models.Gallery
|
||||||
expected *jsonschema.Gallery
|
expected *jsonschema.Gallery
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
galleryNameErr = "galleryNameErr"
|
galleryNameErr = "galleryNameErr"
|
||||||
existingGalleryName = "existingGalleryName"
|
// existingGalleryName = "existingGalleryName"
|
||||||
|
|
||||||
existingGalleryID = 100
|
existingGalleryID = 100
|
||||||
existingStudioID = 101
|
existingStudioID = 101
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
imageID = 1
|
imageID = 1
|
||||||
noImageID = 2
|
// noImageID = 2
|
||||||
errImageID = 3
|
errImageID = 3
|
||||||
|
|
||||||
studioID = 4
|
studioID = 4
|
||||||
@@ -24,17 +24,17 @@ const (
|
|||||||
// noGalleryID = 7
|
// noGalleryID = 7
|
||||||
// errGalleryID = 8
|
// errGalleryID = 8
|
||||||
|
|
||||||
noTagsID = 11
|
// noTagsID = 11
|
||||||
errTagsID = 12
|
errTagsID = 12
|
||||||
|
|
||||||
noMoviesID = 13
|
// noMoviesID = 13
|
||||||
errMoviesID = 14
|
// errMoviesID = 14
|
||||||
errFindMovieID = 15
|
// errFindMovieID = 15
|
||||||
|
|
||||||
noMarkersID = 16
|
// noMarkersID = 16
|
||||||
errMarkersID = 17
|
// errMarkersID = 17
|
||||||
errFindPrimaryTagID = 18
|
// errFindPrimaryTagID = 18
|
||||||
errFindByMarkerID = 19
|
// errFindByMarkerID = 19
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -53,11 +53,6 @@ const (
|
|||||||
//galleryChecksum = "galleryChecksum"
|
//galleryChecksum = "galleryChecksum"
|
||||||
)
|
)
|
||||||
|
|
||||||
var names = []string{
|
|
||||||
"name1",
|
|
||||||
"name2",
|
|
||||||
}
|
|
||||||
|
|
||||||
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
var createTime time.Time = time.Date(2001, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||||
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
var updateTime time.Time = time.Date(2002, 01, 01, 0, 0, 0, 0, time.UTC)
|
||||||
|
|
||||||
@@ -81,18 +76,6 @@ func createFullImage(id int) models.Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyImage(id int) models.Image {
|
|
||||||
return models.Image{
|
|
||||||
ID: id,
|
|
||||||
CreatedAt: models.SQLiteTimestamp{
|
|
||||||
Timestamp: createTime,
|
|
||||||
},
|
|
||||||
UpdatedAt: models.SQLiteTimestamp{
|
|
||||||
Timestamp: updateTime,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func createFullJSONImage() *jsonschema.Image {
|
func createFullJSONImage() *jsonschema.Image {
|
||||||
return &jsonschema.Image{
|
return &jsonschema.Image{
|
||||||
Title: title,
|
Title: title,
|
||||||
@@ -114,18 +97,6 @@ func createFullJSONImage() *jsonschema.Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyJSONImage() *jsonschema.Image {
|
|
||||||
return &jsonschema.Image{
|
|
||||||
File: &jsonschema.ImageFile{},
|
|
||||||
CreatedAt: models.JSONTime{
|
|
||||||
Time: createTime,
|
|
||||||
},
|
|
||||||
UpdatedAt: models.JSONTime{
|
|
||||||
Time: updateTime,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type basicTestScenario struct {
|
type basicTestScenario struct {
|
||||||
input models.Image
|
input models.Image
|
||||||
expected *jsonschema.Image
|
expected *jsonschema.Image
|
||||||
|
|||||||
@@ -11,19 +11,17 @@ import (
|
|||||||
"github.com/stretchr/testify/mock"
|
"github.com/stretchr/testify/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
const invalidImage = "aW1hZ2VCeXRlcw&&"
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
path = "path"
|
path = "path"
|
||||||
|
|
||||||
imageNameErr = "imageNameErr"
|
imageNameErr = "imageNameErr"
|
||||||
existingImageName = "existingImageName"
|
// existingImageName = "existingImageName"
|
||||||
|
|
||||||
existingImageID = 100
|
existingImageID = 100
|
||||||
existingStudioID = 101
|
existingStudioID = 101
|
||||||
existingGalleryID = 102
|
existingGalleryID = 102
|
||||||
existingPerformerID = 103
|
existingPerformerID = 103
|
||||||
existingMovieID = 104
|
// existingMovieID = 104
|
||||||
existingTagID = 105
|
existingTagID = 105
|
||||||
|
|
||||||
existingStudioName = "existingStudioName"
|
existingStudioName = "existingStudioName"
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ func Init(logFile string, logOut bool, logLevel string) {
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Could not open '%s' for log output due to error: %s\n", logFile, err.Error())
|
fmt.Printf("Could not open '%s' for log output due to error: %s\n", logFile, err.Error())
|
||||||
logFile = ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
"github.com/stashapp/stash/pkg/tag"
|
"github.com/stashapp/stash/pkg/tag"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type parserField struct {
|
type parserField struct {
|
||||||
@@ -52,10 +50,6 @@ func (f parserField) replaceInPattern(pattern string) string {
|
|||||||
return string(f.fieldRegex.ReplaceAllString(pattern, f.regex))
|
return string(f.fieldRegex.ReplaceAllString(pattern, f.regex))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f parserField) getFieldPattern() string {
|
|
||||||
return "{" + f.field + "}"
|
|
||||||
}
|
|
||||||
|
|
||||||
var validFields map[string]parserField
|
var validFields map[string]parserField
|
||||||
var escapeCharRE *regexp.Regexp
|
var escapeCharRE *regexp.Regexp
|
||||||
var capitalizeTitleRE *regexp.Regexp
|
var capitalizeTitleRE *regexp.Regexp
|
||||||
@@ -405,26 +399,6 @@ func (m parseMapper) parse(scene *models.Scene) *sceneHolder {
|
|||||||
return sceneHolder
|
return sceneHolder
|
||||||
}
|
}
|
||||||
|
|
||||||
type performerQueryer interface {
|
|
||||||
FindByNames(names []string, tx *sqlx.Tx, nocase bool) ([]*models.Performer, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type sceneQueryer interface {
|
|
||||||
QueryByPathRegex(findFilter *models.FindFilterType) ([]*models.Scene, int)
|
|
||||||
}
|
|
||||||
|
|
||||||
type tagQueryer interface {
|
|
||||||
FindByName(name string, tx *sqlx.Tx, nocase bool) (*models.Tag, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type studioQueryer interface {
|
|
||||||
FindByName(name string, tx *sqlx.Tx, nocase bool) (*models.Studio, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type movieQueryer interface {
|
|
||||||
FindByName(name string, tx *sqlx.Tx, nocase bool) (*models.Movie, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type SceneFilenameParser struct {
|
type SceneFilenameParser struct {
|
||||||
Pattern string
|
Pattern string
|
||||||
ParserInput models.SceneParserInput
|
ParserInput models.SceneParserInput
|
||||||
|
|||||||
@@ -4,13 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"time"
|
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
)
|
)
|
||||||
|
|
||||||
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)
|
||||||
|
|||||||
@@ -569,101 +569,6 @@ func (t *ImportTask) ImportImages(ctx context.Context) {
|
|||||||
logger.Info("[images] import complete")
|
logger.Info("[images] import complete")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *ImportTask) getPerformers(names []string, qb models.PerformerReader) ([]*models.Performer, error) {
|
|
||||||
performers, err := qb.FindByNames(names, false)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var pluckedNames []string
|
|
||||||
for _, performer := range performers {
|
|
||||||
if !performer.Name.Valid {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pluckedNames = append(pluckedNames, performer.Name.String)
|
|
||||||
}
|
|
||||||
|
|
||||||
missingPerformers := utils.StrFilter(names, func(name string) bool {
|
|
||||||
return !utils.StrInclude(pluckedNames, name)
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, missingPerformer := range missingPerformers {
|
|
||||||
logger.Warnf("[scenes] performer %s does not exist", missingPerformer)
|
|
||||||
}
|
|
||||||
|
|
||||||
return performers, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ImportTask) getMoviesScenes(input []jsonschema.SceneMovie, sceneID int, mqb models.MovieReader) ([]models.MoviesScenes, error) {
|
|
||||||
var movies []models.MoviesScenes
|
|
||||||
for _, inputMovie := range input {
|
|
||||||
movie, err := mqb.FindByName(inputMovie.MovieName, false)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if movie == nil {
|
|
||||||
logger.Warnf("[scenes] movie %s does not exist", inputMovie.MovieName)
|
|
||||||
} else {
|
|
||||||
toAdd := models.MoviesScenes{
|
|
||||||
MovieID: movie.ID,
|
|
||||||
SceneID: sceneID,
|
|
||||||
}
|
|
||||||
|
|
||||||
if inputMovie.SceneIndex != 0 {
|
|
||||||
toAdd.SceneIndex = sql.NullInt64{
|
|
||||||
Int64: int64(inputMovie.SceneIndex),
|
|
||||||
Valid: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
movies = append(movies, toAdd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return movies, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *ImportTask) getTags(sceneChecksum string, names []string, tqb models.TagReader) ([]*models.Tag, error) {
|
|
||||||
tags, err := tqb.FindByNames(names, false)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
var pluckedNames []string
|
|
||||||
for _, tag := range tags {
|
|
||||||
if tag.Name == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
pluckedNames = append(pluckedNames, tag.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
missingTags := utils.StrFilter(names, func(name string) bool {
|
|
||||||
return !utils.StrInclude(pluckedNames, name)
|
|
||||||
})
|
|
||||||
|
|
||||||
for _, missingTag := range missingTags {
|
|
||||||
logger.Warnf("[scenes] <%s> tag %s does not exist", sceneChecksum, missingTag)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tags, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://www.reddit.com/r/golang/comments/5ia523/idiomatic_way_to_remove_duplicates_in_a_slice/db6qa2e
|
|
||||||
func (t *ImportTask) getUnique(s []string) []string {
|
|
||||||
seen := make(map[string]struct{}, len(s))
|
|
||||||
j := 0
|
|
||||||
for _, v := range s {
|
|
||||||
if _, ok := seen[v]; ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
seen[v] = struct{}{}
|
|
||||||
s[j] = v
|
|
||||||
j++
|
|
||||||
}
|
|
||||||
return s[:j]
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentLocation = time.Now().Location()
|
var currentLocation = time.Now().Location()
|
||||||
|
|
||||||
func (t *ImportTask) getTimeFromJSONTime(jsonTime models.JSONTime) time.Time {
|
func (t *ImportTask) getTimeFromJSONTime(jsonTime models.JSONTime) time.Time {
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ const (
|
|||||||
missingStudioID = 5
|
missingStudioID = 5
|
||||||
errStudioID = 6
|
errStudioID = 6
|
||||||
|
|
||||||
noGalleryID = 7
|
// noGalleryID = 7
|
||||||
errGalleryID = 8
|
// errGalleryID = 8
|
||||||
|
|
||||||
noTagsID = 11
|
noTagsID = 11
|
||||||
errTagsID = 12
|
errTagsID = 12
|
||||||
@@ -65,7 +65,7 @@ const (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
studioName = "studioName"
|
studioName = "studioName"
|
||||||
galleryChecksum = "galleryChecksum"
|
// galleryChecksum = "galleryChecksum"
|
||||||
|
|
||||||
validMovie1 = 1
|
validMovie1 = 1
|
||||||
validMovie2 = 2
|
validMovie2 = 2
|
||||||
@@ -293,24 +293,6 @@ func TestGetStudioName(t *testing.T) {
|
|||||||
mockStudioReader.AssertExpectations(t)
|
mockStudioReader.AssertExpectations(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
var getGalleryChecksumScenarios = []stringTestScenario{
|
|
||||||
{
|
|
||||||
createEmptyScene(sceneID),
|
|
||||||
galleryChecksum,
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
createEmptyScene(noGalleryID),
|
|
||||||
"",
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
createEmptyScene(errGalleryID),
|
|
||||||
"",
|
|
||||||
true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type stringSliceTestScenario struct {
|
type stringSliceTestScenario struct {
|
||||||
input models.Scene
|
input models.Scene
|
||||||
expected []string
|
expected []string
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const (
|
|||||||
path = "path"
|
path = "path"
|
||||||
|
|
||||||
sceneNameErr = "sceneNameErr"
|
sceneNameErr = "sceneNameErr"
|
||||||
existingSceneName = "existingSceneName"
|
// existingSceneName = "existingSceneName"
|
||||||
|
|
||||||
existingSceneID = 100
|
existingSceneID = 100
|
||||||
existingStudioID = 101
|
existingStudioID = 101
|
||||||
|
|||||||
@@ -11,13 +11,6 @@ const (
|
|||||||
scraperActionJson scraperAction = "scrapeJson"
|
scraperActionJson scraperAction = "scrapeJson"
|
||||||
)
|
)
|
||||||
|
|
||||||
var allScraperAction = []scraperAction{
|
|
||||||
scraperActionScript,
|
|
||||||
scraperActionStash,
|
|
||||||
scraperActionXPath,
|
|
||||||
scraperActionJson,
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e scraperAction) IsValid() bool {
|
func (e scraperAction) IsValid() bool {
|
||||||
switch e {
|
switch e {
|
||||||
case scraperActionScript, scraperActionStash, scraperActionXPath, scraperActionJson:
|
case scraperActionScript, scraperActionStash, scraperActionXPath, scraperActionJson:
|
||||||
@@ -26,12 +19,6 @@ func (e scraperAction) IsValid() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
type scrapeOptions struct {
|
|
||||||
scraper scraperTypeConfig
|
|
||||||
config config
|
|
||||||
globalConfig GlobalConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
type scraper interface {
|
type scraper interface {
|
||||||
scrapePerformersByName(name string) ([]*models.ScrapedPerformer, error)
|
scrapePerformersByName(name string) ([]*models.ScrapedPerformer, error)
|
||||||
scrapePerformerByFragment(scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error)
|
scrapePerformerByFragment(scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error)
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ func (a mappedPostProcessAction) ToPostProcessAction() (postProcessAction, error
|
|||||||
if found != "" {
|
if found != "" {
|
||||||
return nil, fmt.Errorf("post-process actions must have a single field, found %s and %s", found, "subtractDays")
|
return nil, fmt.Errorf("post-process actions must have a single field, found %s and %s", found, "subtractDays")
|
||||||
}
|
}
|
||||||
found = "subtractDays"
|
// found = "subtractDays"
|
||||||
action := postProcessSubtractDays(a.SubtractDays)
|
action := postProcessSubtractDays(a.SubtractDays)
|
||||||
ret = &action
|
ret = &action
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,17 +235,6 @@ func getRemoteCDPWSAddress(address string) (string, error) {
|
|||||||
return remote, err
|
return remote, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func cdpNetwork(enable bool) chromedp.Action {
|
|
||||||
return chromedp.ActionFunc(func(ctx context.Context) error {
|
|
||||||
if enable {
|
|
||||||
network.Enable().Do(ctx)
|
|
||||||
} else {
|
|
||||||
network.Disable().Do(ctx)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func cdpHeaders(driverOptions scraperDriverOptions) map[string]interface{} {
|
func cdpHeaders(driverOptions scraperDriverOptions) map[string]interface{} {
|
||||||
headers := map[string]interface{}{}
|
headers := map[string]interface{}{}
|
||||||
if driverOptions.Headers != nil {
|
if driverOptions.Headers != nil {
|
||||||
|
|||||||
@@ -173,19 +173,6 @@ func setVisitedPlugins(ctx context.Context, visitedPlugins []string) context.Con
|
|||||||
return context.WithValue(ctx, contextVisitedPlugins, visitedPlugins)
|
return context.WithValue(ctx, contextVisitedPlugins, visitedPlugins)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) createSessionCookie(username string) (*http.Cookie, error) {
|
|
||||||
session := sessions.NewSession(s.sessionStore, cookieName)
|
|
||||||
session.Values[userIDKey] = username
|
|
||||||
|
|
||||||
encoded, err := securecookie.EncodeMulti(session.Name(), session.Values,
|
|
||||||
s.sessionStore.Codecs...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return sessions.NewCookie(session.Name(), encoded, session.Options), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Store) MakePluginCookie(ctx context.Context) *http.Cookie {
|
func (s *Store) MakePluginCookie(ctx context.Context) *http.Cookie {
|
||||||
currentUser := GetCurrentUserID(ctx)
|
currentUser := GetCurrentUserID(ctx)
|
||||||
visitedPlugins := GetVisitedPlugins(ctx)
|
visitedPlugins := GetVisitedPlugins(ctx)
|
||||||
|
|||||||
@@ -389,14 +389,6 @@ func boolCriterionHandler(c *bool, column string) criterionHandlerFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringLiteralCriterionHandler(v *string, column string) criterionHandlerFunc {
|
|
||||||
return func(f *filterBuilder) {
|
|
||||||
if v != nil {
|
|
||||||
f.addWhere(column+" = ?", v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle for MultiCriterion where there is a join table between the new
|
// handle for MultiCriterion where there is a join table between the new
|
||||||
// objects
|
// objects
|
||||||
type joinedMultiCriterionHandlerBuilder struct {
|
type joinedMultiCriterionHandlerBuilder struct {
|
||||||
|
|||||||
@@ -311,17 +311,6 @@ func galleryIsMissingCriterionHandler(qb *galleryQueryBuilder, isMissing *string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qb *galleryQueryBuilder) getMultiCriterionHandlerBuilder(foreignTable, joinTable, foreignFK string, addJoinsFunc func(f *filterBuilder)) multiCriterionHandlerBuilder {
|
|
||||||
return multiCriterionHandlerBuilder{
|
|
||||||
primaryTable: galleryTable,
|
|
||||||
foreignTable: foreignTable,
|
|
||||||
joinTable: joinTable,
|
|
||||||
primaryFK: galleryIDColumn,
|
|
||||||
foreignFK: foreignFK,
|
|
||||||
addJoinsFunc: addJoinsFunc,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func galleryTagsCriterionHandler(qb *galleryQueryBuilder, tags *models.MultiCriterionInput) criterionHandlerFunc {
|
func galleryTagsCriterionHandler(qb *galleryQueryBuilder, tags *models.MultiCriterionInput) criterionHandlerFunc {
|
||||||
h := joinedMultiCriterionHandlerBuilder{
|
h := joinedMultiCriterionHandlerBuilder{
|
||||||
primaryTable: galleryTable,
|
primaryTable: galleryTable,
|
||||||
|
|||||||
@@ -72,14 +72,6 @@ func (qb *scrapedItemQueryBuilder) getScrapedItemsSort(findFilter *models.FindFi
|
|||||||
return getSort(sort, direction, "scraped_items")
|
return getSort(sort, direction, "scraped_items")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (qb *scrapedItemQueryBuilder) queryScrapedItem(query string, args []interface{}) (*models.ScrapedItem, error) {
|
|
||||||
results, err := qb.queryScrapedItems(query, args)
|
|
||||||
if err != nil || len(results) < 1 {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return results[0], nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (qb *scrapedItemQueryBuilder) queryScrapedItems(query string, args []interface{}) ([]*models.ScrapedItem, error) {
|
func (qb *scrapedItemQueryBuilder) queryScrapedItems(query string, args []interface{}) ([]*models.ScrapedItem, error) {
|
||||||
var ret models.ScrapedItems
|
var ret models.ScrapedItems
|
||||||
if err := qb.query(query, args, &ret); err != nil {
|
if err := qb.query(query, args, &ret); err != nil {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
|
||||||
"github.com/stashapp/stash/pkg/logger"
|
"github.com/stashapp/stash/pkg/logger"
|
||||||
"github.com/stashapp/stash/pkg/models"
|
"github.com/stashapp/stash/pkg/models"
|
||||||
)
|
)
|
||||||
@@ -148,32 +147,6 @@ func getInBinding(length int) string {
|
|||||||
return "(" + bindings + ")"
|
return "(" + bindings + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
func getCriterionModifierBinding(criterionModifier models.CriterionModifier, value interface{}) (string, int) {
|
|
||||||
var length int
|
|
||||||
switch x := value.(type) {
|
|
||||||
case []string:
|
|
||||||
length = len(x)
|
|
||||||
case []int:
|
|
||||||
length = len(x)
|
|
||||||
default:
|
|
||||||
length = 1
|
|
||||||
}
|
|
||||||
if modifier := criterionModifier.String(); criterionModifier.IsValid() {
|
|
||||||
switch modifier {
|
|
||||||
case "EQUALS", "NOT_EQUALS", "GREATER_THAN", "LESS_THAN", "IS_NULL", "NOT_NULL", "BETWEEN", "NOT_BETWEEN":
|
|
||||||
return getSimpleCriterionClause(criterionModifier, "?")
|
|
||||||
case "INCLUDES":
|
|
||||||
return "IN " + getInBinding(length), length // TODO?
|
|
||||||
case "EXCLUDES":
|
|
||||||
return "NOT IN " + getInBinding(length), length // TODO?
|
|
||||||
default:
|
|
||||||
logger.Errorf("todo")
|
|
||||||
return "= ?", 1 // TODO
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "= ?", 1 // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSimpleCriterionClause(criterionModifier models.CriterionModifier, rhs string) (string, int) {
|
func getSimpleCriterionClause(criterionModifier models.CriterionModifier, rhs string) (string, int) {
|
||||||
if modifier := criterionModifier.String(); criterionModifier.IsValid() {
|
if modifier := criterionModifier.String(); criterionModifier.IsValid() {
|
||||||
switch modifier {
|
switch modifier {
|
||||||
@@ -252,12 +225,6 @@ func getCountCriterionClause(primaryTable, joinTable, primaryFK string, criterio
|
|||||||
return getIntCriterionWhereClause(lhs, criterion)
|
return getIntCriterionWhereClause(lhs, criterion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ensureTx(tx *sqlx.Tx) {
|
|
||||||
if tx == nil {
|
|
||||||
panic("must use a transaction")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getImage(tx dbi, query string, args ...interface{}) ([]byte, error) {
|
func getImage(tx dbi, query string, args ...interface{}) ([]byte, error) {
|
||||||
rows, err := tx.Queryx(query, args...)
|
rows, err := tx.Queryx(query, args...)
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,6 @@ func CreateByteRange(s string) ByteRange {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ByteRange) getBytesToRead() int64 {
|
|
||||||
if r.End == nil {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
return *r.End - r.Start + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r ByteRange) ToHeaderValue(fileLength int64) string {
|
func (r ByteRange) ToHeaderValue(fileLength int64) string {
|
||||||
if r.End == nil {
|
if r.End == nil {
|
||||||
return ""
|
return ""
|
||||||
|
|||||||
Reference in New Issue
Block a user