Fix data path

This commit is contained in:
Benedikt Kulmann
2020-08-19 10:20:53 +02:00
parent 3cb272e76e
commit acff61c406
5 changed files with 17 additions and 17 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package assets
import ( import (
"net/http" "net/http"
"os" "os"
"path" "path/filepath"
"github.com/owncloud/ocis-pkg/v2/log" "github.com/owncloud/ocis-pkg/v2/log"
"github.com/owncloud/ocis-settings/pkg/config" "github.com/owncloud/ocis-settings/pkg/config"
@@ -27,7 +27,7 @@ type assets struct {
func (a assets) Open(original string) (http.File, error) { func (a assets) Open(original string) (http.File, error) {
if a.config.Asset.Path != "" { if a.config.Asset.Path != "" {
if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() { if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() {
custom := path.Join( custom := filepath.Join(
a.config.Asset.Path, a.config.Asset.Path,
original, original,
) )
+1 -1
View File
@@ -44,7 +44,7 @@ type Asset struct {
// Storage defines the available storage configuration. // Storage defines the available storage configuration.
type Storage struct { type Storage struct {
RootMountPath string DataPath string
} }
// TokenManager is the config for using the reva token manager // TokenManager is the config for using the reva token manager
+4 -3
View File
@@ -158,10 +158,11 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
Destination: &cfg.GRPC.Namespace, Destination: &cfg.GRPC.Namespace,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "mount-path", Name: "data-path",
Value: "/var/tmp/ocis-settings",
Usage: "Mount path for the storage", Usage: "Mount path for the storage",
EnvVars: []string{"SETTINGS_ROOT_MOUNT_PATH"}, EnvVars: []string{"SETTINGS_DATA_PATH"},
Destination: &cfg.Storage.RootMountPath, Destination: &cfg.Storage.DataPath,
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "jwt-secret", Name: "jwt-secret",
+2 -2
View File
@@ -10,7 +10,7 @@ const folderNameValues = "values"
// buildFolderPathForBundles builds the folder path for storing settings bundles. If mkdir is true, folders in the path will be created if necessary. // buildFolderPathForBundles builds the folder path for storing settings bundles. If mkdir is true, folders in the path will be created if necessary.
func (s Store) buildFolderPathForBundles(mkdir bool) string { func (s Store) buildFolderPathForBundles(mkdir bool) string {
folderPath := filepath.Join(s.mountPath, folderNameBundles) folderPath := filepath.Join(s.dataPath, folderNameBundles)
if mkdir { if mkdir {
s.ensureFolderExists(folderPath) s.ensureFolderExists(folderPath)
} }
@@ -25,7 +25,7 @@ func (s Store) buildFilePathForBundle(bundleID string, mkdir bool) string {
// buildFolderPathForValues builds the folder path for storing settings values. If mkdir is true, folders in the path will be created if necessary. // buildFolderPathForValues builds the folder path for storing settings values. If mkdir is true, folders in the path will be created if necessary.
func (s Store) buildFolderPathForValues(mkdir bool) string { func (s Store) buildFolderPathForValues(mkdir bool) string {
folderPath := filepath.Join(s.mountPath, folderNameValues) folderPath := filepath.Join(s.dataPath, folderNameValues)
if mkdir { if mkdir {
s.ensureFolderExists(folderPath) s.ensureFolderExists(folderPath)
} }
+8 -9
View File
@@ -3,7 +3,6 @@ package store
import ( import (
"os" "os"
"path"
olog "github.com/owncloud/ocis-pkg/v2/log" olog "github.com/owncloud/ocis-pkg/v2/log"
"github.com/owncloud/ocis-settings/pkg/config" "github.com/owncloud/ocis-settings/pkg/config"
@@ -18,8 +17,8 @@ var (
// Store interacts with the filesystem to manage settings information // Store interacts with the filesystem to manage settings information
type Store struct { type Store struct {
mountPath string dataPath string
Logger olog.Logger Logger olog.Logger
} }
// New creates a new store // New creates a new store
@@ -32,16 +31,16 @@ func New(cfg *config.Config) settings.Manager {
), ),
} }
dest := path.Join(cfg.Storage.RootMountPath, Name) if _, err := os.Stat(cfg.Storage.DataPath); err != nil {
if _, err := os.Stat(dest); err != nil { s.Logger.Info().Msgf("creating container on %v", cfg.Storage.DataPath)
s.Logger.Info().Msgf("creating container on %v", dest) err := os.MkdirAll(cfg.Storage.DataPath, 0700)
err := os.MkdirAll(dest, 0700)
if err != nil { if err != nil {
s.Logger.Err(err).Msgf("providing container on %v", dest) s.Logger.Err(err).Msgf("providing container on %v", cfg.Storage.DataPath)
} }
} }
s.mountPath = dest s.dataPath = cfg.Storage.DataPath
return &s return &s
} }