Expose a multi process mutex lock file config

This commit is contained in:
Sergey Stepanov 2021-08-16 01:36:07 +03:00
parent 8246fc6723
commit c865e83143
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
4 changed files with 16 additions and 11 deletions

2
configs/config.yaml vendored
View file

@ -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

View file

@ -24,6 +24,7 @@ type LibretroConfig struct {
}
Repo struct {
Sync bool
ExtLock string
Main LibretroRepoConfig
Secondary LibretroRepoConfig
}

View file

@ -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)
}
}

View file

@ -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 {