Fix data path

This commit is contained in:
Benedikt Kulmann
2020-08-19 10:06:20 +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 (
"net/http"
"os"
"path"
"path/filepath"
"github.com/owncloud/ocis-pkg/v2/log"
"github.com/owncloud/ocis-settings/pkg/config"
@@ -27,7 +27,7 @@ type assets struct {
func (a assets) Open(original string) (http.File, error) {
if a.config.Asset.Path != "" {
if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() {
custom := path.Join(
custom := filepath.Join(
a.config.Asset.Path,
original,
)
+1 -1
View File
@@ -44,7 +44,7 @@ type Asset struct {
// Storage defines the available storage configuration.
type Storage struct {
RootMountPath string
DataPath string
}
// 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,
},
&cli.StringFlag{
Name: "mount-path",
Name: "data-path",
Value: "/var/tmp/ocis-settings",
Usage: "Mount path for the storage",
EnvVars: []string{"SETTINGS_ROOT_MOUNT_PATH"},
Destination: &cfg.Storage.RootMountPath,
EnvVars: []string{"SETTINGS_DATA_PATH"},
Destination: &cfg.Storage.DataPath,
},
&cli.StringFlag{
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.
func (s Store) buildFolderPathForBundles(mkdir bool) string {
folderPath := filepath.Join(s.mountPath, folderNameBundles)
folderPath := filepath.Join(s.dataPath, folderNameBundles)
if mkdir {
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.
func (s Store) buildFolderPathForValues(mkdir bool) string {
folderPath := filepath.Join(s.mountPath, folderNameValues)
folderPath := filepath.Join(s.dataPath, folderNameValues)
if mkdir {
s.ensureFolderExists(folderPath)
}
+8 -9
View File
@@ -3,7 +3,6 @@ package store
import (
"os"
"path"
olog "github.com/owncloud/ocis-pkg/v2/log"
"github.com/owncloud/ocis-settings/pkg/config"
@@ -18,8 +17,8 @@ var (
// Store interacts with the filesystem to manage settings information
type Store struct {
mountPath string
Logger olog.Logger
dataPath string
Logger olog.Logger
}
// 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(dest); err != nil {
s.Logger.Info().Msgf("creating container on %v", dest)
err := os.MkdirAll(dest, 0700)
if _, err := os.Stat(cfg.Storage.DataPath); err != nil {
s.Logger.Info().Msgf("creating container on %v", cfg.Storage.DataPath)
err := os.MkdirAll(cfg.Storage.DataPath, 0700)
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
}