put store lock file in base of storage

This commit is contained in:
tsmethurst 2022-01-29 12:16:12 +01:00
parent 4e74c84148
commit d9a778a795
2 changed files with 10 additions and 3 deletions

View File

@ -24,9 +24,11 @@ import (
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"path"
"syscall" "syscall"
"codeberg.org/gruf/go-store/kv" "codeberg.org/gruf/go-store/kv"
"codeberg.org/gruf/go-store/storage"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action" "github.com/superseriousbusiness/gotosocial/cmd/gotosocial/action"
@ -99,7 +101,9 @@ var Start action.GTSAction = func(ctx context.Context) error {
// Open the storage backend // Open the storage backend
storageBasePath := viper.GetString(config.Keys.StorageLocalBasePath) storageBasePath := viper.GetString(config.Keys.StorageLocalBasePath)
storage, err := kv.OpenFile(storageBasePath, nil) storage, err := kv.OpenFile(storageBasePath, &storage.DiskConfig{
LockFile: path.Join(storageBasePath, "store.lock"), // put the store lockfile in the storage dir itself
})
if err != nil { if err != nil {
return fmt.Errorf("error creating storage backend: %s", err) return fmt.Errorf("error creating storage backend: %s", err)
} }

View File

@ -24,6 +24,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"path"
"testing" "testing"
"time" "time"
@ -284,10 +285,12 @@ func (suite *ManagerTestSuite) TestSimpleJpegProcessBlockingWithDiskStorage() {
accountID := "01FS1X72SK9ZPW0J1QQ68BD264" accountID := "01FS1X72SK9ZPW0J1QQ68BD264"
temp := fmt.Sprintf("%s/store", os.TempDir()) temp := fmt.Sprintf("%s/gotosocial-test", os.TempDir())
defer os.RemoveAll(temp) defer os.RemoveAll(temp)
diskStorage, err := kv.OpenFile(temp, &storage.DiskConfig{}) diskStorage, err := kv.OpenFile(temp, &storage.DiskConfig{
LockFile: path.Join(temp, "store.lock"),
})
if err != nil { if err != nil {
panic(err) panic(err)
} }