Fix ffmpeg resolution when in current directory (#4899)

* Use absolute path to resolve ffmpeg in config directory
* Pass absolute config path to plugins
This commit is contained in:
WithoutPants 2024-05-30 15:50:27 +10:00 committed by GitHub
parent 2b699fcf95
commit 3b146588c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 4 deletions

View File

@ -27,7 +27,7 @@ func (r *mutationResolver) Setup(ctx context.Context, input manager.SetupInput)
func (r *mutationResolver) DownloadFFMpeg(ctx context.Context) (string, error) {
mgr := manager.GetInstance()
configDir := mgr.Config.GetConfigPath()
configDir := mgr.Config.GetConfigPathAbs()
// don't run if ffmpeg is already installed
ffmpegPath := ffmpeg.FindFFMpeg(configDir)

View File

@ -496,6 +496,20 @@ func (i *Config) GetConfigPath() string {
return filepath.Dir(i.GetConfigFile())
}
// GetConfigPathAbs returns the path of the directory containing the used
// configuration file, resolved to an absolute path. Returns the return value
// of GetConfigPath if the path cannot be made into an absolute path.
func (i *Config) GetConfigPathAbs() string {
p := filepath.Dir(i.GetConfigFile())
ret, _ := filepath.Abs(p)
if ret == "" {
return p
}
return ret
}
// GetDefaultDatabaseFilePath returns the default database filename,
// which is located in the same directory as the config file.
func (i *Config) GetDefaultDatabaseFilePath() string {

View File

@ -260,7 +260,9 @@ func (s *Manager) writeStashIcon() {
func (s *Manager) RefreshFFMpeg(ctx context.Context) {
// use same directory as config path
configDirectory := s.Config.GetConfigPath()
// executing binaries requires directory to be included
// https://pkg.go.dev/os/exec#hdr-Executables_in_the_current_directory
configDirectory := s.Config.GetConfigPathAbs()
stashHomeDir := paths.GetStashHomeDirectory()
// prefer the configured paths

View File

@ -91,7 +91,7 @@ type PluginSetting struct {
type ServerConfig interface {
GetHost() string
GetPort() int
GetConfigPath() string
GetConfigPathAbs() string
HasTLSConfig() bool
GetPluginsPath() string
GetDisabledPlugins() []string
@ -249,7 +249,7 @@ func (c Cache) makeServerConnection(ctx context.Context) common.StashServerConne
Host: c.config.GetHost(),
Port: c.config.GetPort(),
SessionCookie: cookie,
Dir: c.config.GetConfigPath(),
Dir: c.config.GetConfigPathAbs(),
}
if c.config.HasTLSConfig() {