mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-24 22:19:09 -05:00
Fix data path
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user