diff --git a/configs/config.yaml b/configs/config.yaml index a767761d..c4a13f10 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -114,6 +114,8 @@ emulator: repo: # enable auto-download for the list of cores (list->lib) sync: true + # external cross-process mutex lock + extLock: "{user}/.cr/cloud-game.lock" main: type: buildbot url: https://buildbot.libretro.com/nightly diff --git a/pkg/config/emulator/config.go b/pkg/config/emulator/config.go index ebb51135..0b2af352 100644 --- a/pkg/config/emulator/config.go +++ b/pkg/config/emulator/config.go @@ -24,6 +24,7 @@ type LibretroConfig struct { } Repo struct { Sync bool + ExtLock string Main LibretroRepoConfig Secondary LibretroRepoConfig } diff --git a/pkg/config/worker/config.go b/pkg/config/worker/config.go index c76e181b..ccd5ea10 100644 --- a/pkg/config/worker/config.go +++ b/pkg/config/worker/config.go @@ -61,17 +61,16 @@ func (c *Config) ParseFlags() { // expandSpecialTags replaces all the special tags in the config. func (c *Config) expandSpecialTags() { - // home dir - dir := c.Emulator.Storage - if dir != "" { - tag := "{user}" - if strings.Contains(dir, tag) { - userHomeDir, err := environment.GetUserHome() - if err != nil { - log.Fatalln("couldn't read user home directory", err) - } - c.Emulator.Storage = strings.Replace(dir, tag, userHomeDir, -1) + tag := "{user}" + for _, dir := range []*string{&c.Emulator.Storage, &c.Emulator.Libretro.Cores.Repo.ExtLock} { + if *dir == "" || !strings.Contains(*dir, tag) { + continue } + userHomeDir, err := environment.GetUserHome() + if err != nil { + log.Fatalln("couldn't read user home directory", err) + } + *dir = strings.Replace(*dir, tag, userHomeDir, -1) } } diff --git a/pkg/emulator/libretro/manager/remotehttp/manager.go b/pkg/emulator/libretro/manager/remotehttp/manager.go index 4c0e7fca..f05ba802 100644 --- a/pkg/emulator/libretro/manager/remotehttp/manager.go +++ b/pkg/emulator/libretro/manager/remotehttp/manager.go @@ -26,7 +26,10 @@ type Manager struct { func NewRemoteHttpManager(conf emulator.LibretroConfig) Manager { repoConf := conf.Cores.Repo.Main // used for synchronization of multiple process - fileLock := os.TempDir() + string(os.PathSeparator) + "cloud_game.lock" + fileLock := conf.Cores.Repo.ExtLock + if fileLock == "" { + fileLock = os.TempDir() + string(os.PathSeparator) + "cloud_game.lock" + } arch, err := core.GetCoreExt() if err != nil {