Fix: unhandled errors (#1419)

As these errors where not explicitly ignored with _, I made changes to make sure they bubble up.
This commit is contained in:
EnameEtavir 2021-05-25 10:40:51 +02:00 committed by GitHub
parent 65baf46c40
commit d6ada23616
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 9 deletions

View File

@ -406,6 +406,9 @@ func (r *mutationResolver) ScenesDestroy(ctx context.Context, input models.Scene
sceneID, _ := strconv.Atoi(id)
scene, err := qb.Find(sceneID)
if err != nil {
return err
}
if scene != nil {
scenes = append(scenes, scene)
}

View File

@ -13,17 +13,25 @@ func (r *queryResolver) Configuration(ctx context.Context) (*models.ConfigResult
}
func (r *queryResolver) Directory(ctx context.Context, path *string) (*models.Directory, error) {
directory := &models.Directory{}
var err error
var dirPath = ""
if path != nil {
dirPath = *path
}
currentDir := utils.GetDir(dirPath)
directories, err := utils.ListDir(currentDir)
if err != nil {
return directory, err
}
return &models.Directory{
Path: currentDir,
Parent: utils.GetParent(currentDir),
Directories: utils.ListDir(currentDir),
}, nil
directory.Path = currentDir
directory.Parent = utils.GetParent(currentDir)
directory.Directories = directories
return directory, err
}
func makeConfigResult() *models.ConfigResult {

View File

@ -21,6 +21,9 @@ func (r *queryResolver) FindImage(ctx context.Context, id *string, checksum *str
}
image, err = qb.Find(idInt)
if err != nil {
return err
}
} else if checksum != nil {
image, err = qb.FindByChecksum(*checksum)
}

View File

@ -19,6 +19,9 @@ func (r *queryResolver) FindScene(ctx context.Context, id *string, checksum *str
return err
}
scene, err = qb.Find(idInt)
if err != nil {
return err
}
} else if checksum != nil {
scene, err = qb.FindByChecksum(*checksum)
}

View File

@ -217,6 +217,9 @@ func unzip(src, configDirectory string) error {
}
rc, err := f.Open()
if err != nil {
return err
}
unzippedPath := filepath.Join(configDirectory, filename)
unzippedOutput, err := os.Create(unzippedPath)

View File

@ -120,6 +120,9 @@ func (g *SpriteGenerator) generateSpriteVTT(encoder *ffmpeg.Encoder) error {
defer spriteImage.Close()
spriteImageName := filepath.Base(g.ImageOutputPath)
image, _, err := image.DecodeConfig(spriteImage)
if err != nil {
return err
}
width := image.Width / g.Columns
height := image.Height / g.Rows

View File

@ -174,6 +174,9 @@ func (t *StashBoxPerformerTagTask) stashBoxPerformerTag() {
return err
}
err = r.Performer().UpdateImage(t.performer.ID, image)
if err != nil {
return err
}
}
if err == nil {

View File

@ -106,21 +106,23 @@ func EmptyDir(path string) error {
}
// ListDir will return the contents of a given directory path as a string slice
func ListDir(path string) []string {
func ListDir(path string) ([]string, error) {
var dirPaths []string
files, err := ioutil.ReadDir(path)
if err != nil {
path = filepath.Dir(path)
files, err = ioutil.ReadDir(path)
if err != nil {
return dirPaths, err
}
}
var dirPaths []string
for _, file := range files {
if !file.IsDir() {
continue
}
dirPaths = append(dirPaths, filepath.Join(path, file.Name()))
}
return dirPaths
return dirPaths, nil
}
// GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows