Skip to content

Commit

Permalink
refactor: little fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alxarno committed Jan 12, 2025
1 parent a82b03f commit b04684b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
10 changes: 3 additions & 7 deletions pkg/preview/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@ import (
)

const (
maxWidthHeight = 256
jpegShrinkFactor = 8
maxWidthHeight = 256
)

var (
ErrVipsLoadImage = errors.New("failed load image")
ErrVipsResizeImage = errors.New("failed resize image")
ErrImageDownScale = errors.New("failed to downscale the image")
ErrImageColorSpaceTransform = errors.New("failed to transform the image's color space")
ErrImageExport = errors.New("failed export the image")
ErrVipsLoadImage = errors.New("failed load image")
ErrImageExport = errors.New("failed export the image")
)

func imagePreview(path string) (data, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/preview/preview.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func ifMaxPass(maxNewItems *int64) bool {
return true
}

//nolint:cyclop,ireturn,nolintlint //it's very simple method...
//nolint:cyclop,ireturn,nolintlint
func (p Previewer) Pull(ctx context.Context, src Source) (Data, error) {
defaultPreview := data{}

Expand Down
10 changes: 2 additions & 8 deletions pkg/preview/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import (

var (
ErrPullSnapshot = errors.New("failed to pull snapshot")
ErrImageDecode = errors.New("failed to decode image")
ErrImageCopy = errors.New("failed to copy image")
ErrImagesJoin = errors.New("failed to join images")
ErrImageEncode = errors.New("failed to encode image")
ErrImageScale = errors.New("failed to scale image")
ErrBufferCopy = errors.New("failed to copy buffer")
)

const (
Expand Down Expand Up @@ -80,11 +74,11 @@ func getScreenshots(ctx context.Context, path string, timestamps []time.Duration

mixerErr := mixerCmd.Wait()

if producerErr != nil && errors.Is(producerErr, context.Canceled) {
if producerErr != nil && !errors.Is(producerErr, context.Canceled) {
return nil, fmt.Errorf("producer error [%s] %w", producerErrBuff.String(), producerErr)
}

if mixerErr != nil && errors.Is(mixerErr, context.Canceled) {
if mixerErr != nil && !errors.Is(mixerErr, context.Canceled) {
return nil, fmt.Errorf("mixer error [%s] %w", mixerErrBuff.String(), mixerErr)
}

Expand Down

0 comments on commit b04684b

Please sign in to comment.