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) sceneID, _ := strconv.Atoi(id)
scene, err := qb.Find(sceneID) scene, err := qb.Find(sceneID)
if err != nil {
return err
}
if scene != nil { if scene != nil {
scenes = append(scenes, scene) 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) { func (r *queryResolver) Directory(ctx context.Context, path *string) (*models.Directory, error) {
directory := &models.Directory{}
var err error
var dirPath = "" var dirPath = ""
if path != nil { if path != nil {
dirPath = *path dirPath = *path
} }
currentDir := utils.GetDir(dirPath) currentDir := utils.GetDir(dirPath)
directories, err := utils.ListDir(currentDir)
if err != nil {
return directory, err
}
return &models.Directory{ directory.Path = currentDir
Path: currentDir, directory.Parent = utils.GetParent(currentDir)
Parent: utils.GetParent(currentDir), directory.Directories = directories
Directories: utils.ListDir(currentDir),
}, nil return directory, err
} }
func makeConfigResult() *models.ConfigResult { 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) image, err = qb.Find(idInt)
if err != nil {
return err
}
} else if checksum != nil { } else if checksum != nil {
image, err = qb.FindByChecksum(*checksum) image, err = qb.FindByChecksum(*checksum)
} }

View file

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

View file

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

View file

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

View file

@ -174,6 +174,9 @@ func (t *StashBoxPerformerTagTask) stashBoxPerformerTag() {
return err return err
} }
err = r.Performer().UpdateImage(t.performer.ID, image) err = r.Performer().UpdateImage(t.performer.ID, image)
if err != nil {
return err
}
} }
if err == nil { 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 // 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) files, err := ioutil.ReadDir(path)
if err != nil { if err != nil {
path = filepath.Dir(path) path = filepath.Dir(path)
files, err = ioutil.ReadDir(path) files, err = ioutil.ReadDir(path)
if err != nil {
return dirPaths, err
}
} }
var dirPaths []string
for _, file := range files { for _, file := range files {
if !file.IsDir() { if !file.IsDir() {
continue continue
} }
dirPaths = append(dirPaths, filepath.Join(path, file.Name())) 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 // GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows