aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-16 14:24:49 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-16 14:27:40 +0200
commit4feef5296bf3aea331fdde4cd7b94ee2322a907e (patch)
tree764618c74a241a7ce53a07e0105b01a4fb07f9c6 /lib
parentdd6f08b10b1597f44e3dc25509ac9a45336b0914 (diff)
Moved project creation in a modal windows
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib')
-rw-r--r--lib/folder/folder-pathmap.go20
-rw-r--r--lib/model/folders.go2
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/folder/folder-pathmap.go b/lib/folder/folder-pathmap.go
index 8711df2..2ad8a93 100644
--- a/lib/folder/folder-pathmap.go
+++ b/lib/folder/folder-pathmap.go
@@ -7,18 +7,22 @@ import (
"path/filepath"
common "github.com/iotbzh/xds-common/golib"
+ "github.com/iotbzh/xds-server/lib/xdsconfig"
)
// IFOLDER interface implementation for native/path mapping folders
// PathMap .
type PathMap struct {
- config FolderConfig
+ globalConfig *xdsconfig.Config
+ config FolderConfig
}
// NewFolderPathMap Create a new instance of PathMap
-func NewFolderPathMap() *PathMap {
- f := PathMap{}
+func NewFolderPathMap(gc *xdsconfig.Config) *PathMap {
+ f := PathMap{
+ globalConfig: gc,
+ }
return &f
}
@@ -28,8 +32,13 @@ func (f *PathMap) Add(cfg FolderConfig) (*FolderConfig, error) {
return nil, fmt.Errorf("ServerPath must be set")
}
- // Sanity check
+ // Use shareRootDir if ServerPath is a relative path
dir := cfg.DataPathMap.ServerPath
+ if !filepath.IsAbs(dir) {
+ dir = filepath.Join(f.globalConfig.FileConf.ShareRootDir, dir)
+ }
+
+ // Sanity check
if !common.Exists(dir) {
// try to create if not existing
if err := os.MkdirAll(dir, 0755); err != nil {
@@ -52,7 +61,8 @@ func (f *PathMap) Add(cfg FolderConfig) (*FolderConfig, error) {
}
f.config = cfg
- f.config.RootPath = cfg.DataPathMap.ServerPath
+ f.config.RootPath = dir
+ f.config.DataPathMap.ServerPath = dir
f.config.Status = StatusEnable
return &f.config, nil
diff --git a/lib/model/folders.go b/lib/model/folders.go
index 3c2457c..02c3254 100644
--- a/lib/model/folders.go
+++ b/lib/model/folders.go
@@ -208,7 +208,7 @@ func (f *Folders) createUpdate(newF folder.FolderConfig, create bool) (*folder.F
fld = f.SThg.NewFolderST(f.Conf)
// PATH MAP
case folder.TypePathMap:
- fld = folder.NewFolderPathMap()
+ fld = folder.NewFolderPathMap(f.Conf)
default:
return nil, fmt.Errorf("Unsupported folder type")
}