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) { func (r *mutationResolver) DownloadFFMpeg(ctx context.Context) (string, error) {
mgr := manager.GetInstance() mgr := manager.GetInstance()
configDir := mgr.Config.GetConfigPath() configDir := mgr.Config.GetConfigPathAbs()
// don't run if ffmpeg is already installed // don't run if ffmpeg is already installed
ffmpegPath := ffmpeg.FindFFMpeg(configDir) ffmpegPath := ffmpeg.FindFFMpeg(configDir)

View file

@ -496,6 +496,20 @@ func (i *Config) GetConfigPath() string {
return filepath.Dir(i.GetConfigFile()) 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, // GetDefaultDatabaseFilePath returns the default database filename,
// which is located in the same directory as the config file. // which is located in the same directory as the config file.
func (i *Config) GetDefaultDatabaseFilePath() string { func (i *Config) GetDefaultDatabaseFilePath() string {

View file

@ -260,7 +260,9 @@ func (s *Manager) writeStashIcon() {
func (s *Manager) RefreshFFMpeg(ctx context.Context) { func (s *Manager) RefreshFFMpeg(ctx context.Context) {
// use same directory as config path // 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() stashHomeDir := paths.GetStashHomeDirectory()
// prefer the configured paths // prefer the configured paths

View file

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