aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syncthing
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-28 21:44:26 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-29 08:56:46 +0200
commitd94141ed7419867231a1050eb81c72bfd25003c6 (patch)
tree5ea9d86d2769527354d42853949f28d5b0c030e0 /lib/syncthing
parent29b13449d2e8a5dad2aefda6e9a2b5661fecfc2a (diff)
Fixed path convertion/mapping for in/out and for command args.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/syncthing')
-rw-r--r--lib/syncthing/folder-st.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/syncthing/folder-st.go b/lib/syncthing/folder-st.go
index da27062..a372b6f 100644
--- a/lib/syncthing/folder-st.go
+++ b/lib/syncthing/folder-st.go
@@ -3,6 +3,7 @@ package st
import (
"fmt"
"path/filepath"
+ "strings"
"github.com/iotbzh/xds-server/lib/folder"
"github.com/iotbzh/xds-server/lib/xdsconfig"
@@ -93,7 +94,7 @@ func (f *STFolder) GetConfig() folder.FolderConfig {
return f.fConfig
}
-// GetFullPath returns the full path
+// GetFullPath returns the full path of a directory (from server POV)
func (f *STFolder) GetFullPath(dir string) string {
if &dir == nil {
dir = ""
@@ -104,6 +105,28 @@ func (f *STFolder) GetFullPath(dir string) string {
return filepath.Join(f.fConfig.RootPath, f.fConfig.ClientPath, dir)
}
+// ConvPathCli2Svr Convert path from Client to Server
+func (f *STFolder) ConvPathCli2Svr(s string) string {
+ if f.fConfig.ClientPath != "" && f.fConfig.RootPath != "" {
+ return strings.Replace(s,
+ f.fConfig.ClientPath,
+ f.fConfig.RootPath+"/"+f.fConfig.ClientPath,
+ -1)
+ }
+ return s
+}
+
+// ConvPathSvr2Cli Convert path from Server to Client
+func (f *STFolder) ConvPathSvr2Cli(s string) string {
+ if f.fConfig.ClientPath != "" && f.fConfig.RootPath != "" {
+ return strings.Replace(s,
+ f.fConfig.RootPath+"/"+f.fConfig.ClientPath,
+ f.fConfig.ClientPath,
+ -1)
+ }
+ return s
+}
+
// Remove a folder
func (f *STFolder) Remove() error {
return f.st.FolderDelete(f.stfConfig.ID)