Skip to content

Commit

Permalink
fixed unknown field HideWindow in struct literal of type "syscall".Sy…
Browse files Browse the repository at this point in the history
…sProcAttr when compiling for Linux and Darwin
  • Loading branch information
KJHJason committed May 20, 2024
1 parent 6ca65c3 commit c64c190
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
7 changes: 2 additions & 5 deletions api/pixiv/ugoira/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strconv"
"syscall"

"github.com/KJHJason/Cultured-Downloader-Logic/configs"
"github.com/KJHJason/Cultured-Downloader-Logic/constants"
cdlerrors "github.com/KJHJason/Cultured-Downloader-Logic/errors"
"github.com/KJHJason/Cultured-Downloader-Logic/iofuncs"
Expand Down Expand Up @@ -135,9 +134,7 @@ func getFlagsForGif(options *ffmpegOptions, imagesFolderPath string) ([]string,
"-vf", "palettegen",
palettePath,
)
if runtime.GOOS == "windows" {
imagePaletteCmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
configs.PrepareCmdForBgTask(imagePaletteCmd)
if constants.DEBUG_MODE {
imagePaletteCmd.Stdout = os.Stdout
imagePaletteCmd.Stderr = os.Stderr
Expand Down
5 changes: 1 addition & 4 deletions api/pixiv/ugoira/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os/exec"
"os/signal"
"path/filepath"
"runtime"
"sync"
"syscall"

Expand Down Expand Up @@ -73,9 +72,7 @@ func ConvertUgoira(ugoiraInfo *Ugoira, imagesFolderPath string, ugoiraFfmpeg *Ug

// convert the frames to a gif or a video
cmd := exec.CommandContext(ugoiraFfmpeg.context, ugoiraFfmpeg.ffmpegPath, args...)
if runtime.GOOS == "windows" {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
configs.PrepareCmdForBgTask(cmd)
// cmd.Stderr = os.Stderr
// cmd.Stdout = os.Stdout

Expand Down
11 changes: 11 additions & 0 deletions configs/cmd_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build darwin

package configs

import (
"os/exec"
)

func PrepareCmdForBgTask(cmd *exec.Cmd) {
// do nothing
}
11 changes: 11 additions & 0 deletions configs/cmd_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build linux

package configs

import (
"os/exec"
)

func PrepareCmdForBgTask(cmd *exec.Cmd) {
// do nothing
}
12 changes: 12 additions & 0 deletions configs/cmd_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// +build windows

package configs

import (
"os/exec"
"syscall"
)

func PrepareCmdForBgTask(cmd *exec.Cmd) {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
6 changes: 1 addition & 5 deletions configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import (
"context"
"errors"
"os/exec"
"runtime"
"strings"
"syscall"
"time"
)

Expand Down Expand Up @@ -46,9 +44,7 @@ func ValidateFfmpegPathLogic(ctx context.Context, ffmpegPath string) error {

// execute the ffmpeg binary to check if it's working
cmd := exec.CommandContext(cmdCtx, ffmpegPath, "-version")
if runtime.GOOS == "windows" {
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
}
PrepareCmdForBgTask(cmd)
stdout, ffmpegErr := cmd.Output()
if ffmpegErr != nil {
return ffmpegErr
Expand Down

0 comments on commit c64c190

Please sign in to comment.