node build fixed

This commit is contained in:
ra_ma
2025-09-20 14:08:38 +01:00
parent c6ebbe069d
commit 3d298fa434
1516 changed files with 535727 additions and 2 deletions

View File

@@ -0,0 +1,59 @@
package handlers
import (
"os"
"runtime"
"seanime/internal/util"
"strings"
"github.com/labstack/echo/v4"
)
// HandleOpenInExplorer
//
// @summary opens the given directory in the file explorer.
// @desc It returns 'true' whether the operation was successful or not.
// @route /api/v1/open-in-explorer [POST]
// @returns bool
func (h *Handler) HandleOpenInExplorer(c echo.Context) error {
type body struct {
Path string `json:"path"`
}
p := new(body)
if err := c.Bind(p); err != nil {
return h.RespondWithError(c, err)
}
OpenDirInExplorer(p.Path)
return h.RespondWithData(c, true)
}
func OpenDirInExplorer(dir string) {
if dir == "" {
return
}
cmd := ""
var args []string
switch runtime.GOOS {
case "windows":
cmd = "explorer"
args = []string{strings.ReplaceAll(strings.ToLower(dir), "/", "\\")}
case "darwin":
cmd = "open"
args = []string{dir}
case "linux":
cmd = "xdg-open"
args = []string{dir}
default:
return
}
cmdObj := util.NewCmd(cmd, args...)
cmdObj.Stdout = os.Stdout
cmdObj.Stderr = os.Stderr
_ = cmdObj.Run()
}