Move TempFileName to utils
This commit is contained in:
@@ -2,14 +2,11 @@ package mpv
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
@@ -133,10 +130,3 @@ var (
|
||||
mpvPath string
|
||||
mpvErr error
|
||||
)
|
||||
|
||||
func TempFileName(prefix, suffix string) string {
|
||||
randBytes := make([]byte, 16)
|
||||
// we can savely ignore the return value since we're loading into a precreated, fixedsized buffer
|
||||
_, _ = rand.Read(randBytes)
|
||||
return filepath.Join(os.TempDir(), prefix+hex.EncodeToString(randBytes)+suffix)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/dexterlb/mpvipc"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
)
|
||||
|
||||
type MpvTrack struct {
|
||||
@@ -31,7 +32,7 @@ func NewTrack(playbackDoneChannel chan bool, deviceName string, mf model.MediaFi
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tmpSocketName := TempFileName("mpv-ctrl-", ".socket")
|
||||
tmpSocketName := utils.TempFileName("mpv-ctrl-", ".socket")
|
||||
|
||||
args := createMPVCommand(mpvComdTemplate, deviceName, mf.Path, tmpSocketName)
|
||||
exe, err := start(args)
|
||||
|
||||
Reference in New Issue
Block a user