mirror of
https://github.com/stashapp/stash.git
synced 2026-04-27 11:59:17 -05:00
Restructure go project (#2356)
* Move main to cmd * Move api to internal * Move logger and manager to internal * Move shell hiding code to separate package * Decouple job from desktop and utils * Decouple session from config * Move static into internal * Decouple config from dlna * Move desktop to internal * Move dlna to internal * Decouple remaining packages from config * Move config into internal * Move jsonschema and paths to models * Make ffmpeg functions private * Move file utility methods into fsutil package * Move symwalk into fsutil * Move single-use util functions into client package * Move slice functions to separate packages * Add env var to suppress windowsgui arg * Move hash functions into separate package * Move identify to internal * Move autotag to internal * Touch UI when generating backend
This commit is contained in:
+3
-3
@@ -2,9 +2,9 @@ package image
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/manager/paths"
|
||||
"github.com/stashapp/stash/pkg/fsutil"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"github.com/stashapp/stash/pkg/models/paths"
|
||||
)
|
||||
|
||||
type Destroyer interface {
|
||||
@@ -21,7 +21,7 @@ type FileDeleter struct {
|
||||
// MarkGeneratedFiles marks for deletion the generated files for the provided image.
|
||||
func (d *FileDeleter) MarkGeneratedFiles(image *models.Image) error {
|
||||
thumbPath := d.Paths.Generated.GetThumbnailPath(image.Checksum, models.DefaultGthumbWidth)
|
||||
exists, _ := utils.FileExists(thumbPath)
|
||||
exists, _ := fsutil.FileExists(thumbPath)
|
||||
if exists {
|
||||
return d.Files([]string{thumbPath})
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
)
|
||||
|
||||
// ToBasicJSON converts a image object into its JSON object equivalent. It
|
||||
|
||||
@@ -3,8 +3,8 @@ package image
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
|
||||
+4
-3
@@ -13,9 +13,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/fsutil"
|
||||
"github.com/stashapp/stash/pkg/hash/md5"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
_ "golang.org/x/image/webp"
|
||||
)
|
||||
|
||||
@@ -53,7 +54,7 @@ func CalculateMD5(path string) (string, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return utils.MD5FromReader(f)
|
||||
return md5.FromReader(f)
|
||||
}
|
||||
|
||||
func FileExists(path string) bool {
|
||||
@@ -245,5 +246,5 @@ func GetTitle(s *models.Image) string {
|
||||
// If stripExt is set the file extension is omitted from the name
|
||||
func GetFilename(s *models.Image, stripExt bool) string {
|
||||
_, fn := file.ZipFilePath(s.Path)
|
||||
return utils.GetNameFromPath(fn, stripExt)
|
||||
return fsutil.GetNameFromPath(fn, stripExt)
|
||||
}
|
||||
|
||||
+6
-6
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/stringslice"
|
||||
)
|
||||
|
||||
type Importer struct {
|
||||
@@ -167,8 +167,8 @@ func (i *Importer) populatePerformers() error {
|
||||
pluckedNames = append(pluckedNames, performer.Name.String)
|
||||
}
|
||||
|
||||
missingPerformers := utils.StrFilter(names, func(name string) bool {
|
||||
return !utils.StrInclude(pluckedNames, name)
|
||||
missingPerformers := stringslice.StrFilter(names, func(name string) bool {
|
||||
return !stringslice.StrInclude(pluckedNames, name)
|
||||
})
|
||||
|
||||
if len(missingPerformers) > 0 {
|
||||
@@ -315,8 +315,8 @@ func importTags(tagWriter models.TagReaderWriter, names []string, missingRefBeha
|
||||
pluckedNames = append(pluckedNames, tag.Name)
|
||||
}
|
||||
|
||||
missingTags := utils.StrFilter(names, func(name string) bool {
|
||||
return !utils.StrInclude(pluckedNames, name)
|
||||
missingTags := stringslice.StrFilter(names, func(name string) bool {
|
||||
return !stringslice.StrInclude(pluckedNames, name)
|
||||
})
|
||||
|
||||
if len(missingTags) > 0 {
|
||||
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stashapp/stash/pkg/manager/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/jsonschema"
|
||||
"github.com/stashapp/stash/pkg/models/mocks"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
||||
+1
-1
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
"github.com/stashapp/stash/pkg/file"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
"github.com/stashapp/stash/pkg/manager/paths"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/models/paths"
|
||||
"github.com/stashapp/stash/pkg/plugin"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
)
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@ package image
|
||||
|
||||
import (
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"github.com/stashapp/stash/pkg/utils"
|
||||
"github.com/stashapp/stash/pkg/sliceutil/intslice"
|
||||
)
|
||||
|
||||
func UpdateFileModTime(qb models.ImageWriter, id int, modTime models.NullSQLiteTimestamp) (*models.Image, error) {
|
||||
@@ -19,7 +19,7 @@ func AddPerformer(qb models.ImageReaderWriter, id int, performerID int) (bool, e
|
||||
}
|
||||
|
||||
oldLen := len(performerIDs)
|
||||
performerIDs = utils.IntAppendUnique(performerIDs, performerID)
|
||||
performerIDs = intslice.IntAppendUnique(performerIDs, performerID)
|
||||
|
||||
if len(performerIDs) != oldLen {
|
||||
if err := qb.UpdatePerformers(id, performerIDs); err != nil {
|
||||
@@ -39,7 +39,7 @@ func AddTag(qb models.ImageReaderWriter, id int, tagID int) (bool, error) {
|
||||
}
|
||||
|
||||
oldLen := len(tagIDs)
|
||||
tagIDs = utils.IntAppendUnique(tagIDs, tagID)
|
||||
tagIDs = intslice.IntAppendUnique(tagIDs, tagID)
|
||||
|
||||
if len(tagIDs) != oldLen {
|
||||
if err := qb.UpdateTags(id, tagIDs); err != nil {
|
||||
|
||||
+1
-3
@@ -3,10 +3,9 @@ package image
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/stashapp/stash/pkg/desktop"
|
||||
"github.com/stashapp/stash/pkg/exec"
|
||||
"github.com/stashapp/stash/pkg/logger"
|
||||
)
|
||||
|
||||
@@ -33,7 +32,6 @@ func (e *vipsEncoder) run(args []string, stdin *bytes.Buffer) (string, error) {
|
||||
cmd.Stderr = &stderr
|
||||
cmd.Stdin = stdin
|
||||
|
||||
desktop.HideExecShell(cmd)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user