Code Review
/
src
/
xds
/
xds-agent.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add sanity check when adding a new pathmap project/folder
[src/xds/xds-agent.git]
/
lib
/
syncthing
/
stfolder.go
diff --git
a/lib/syncthing/stfolder.go
b/lib/syncthing/stfolder.go
index
d5c74ef
..
196e3c7
100644
(file)
--- a/
lib/syncthing/stfolder.go
+++ b/
lib/syncthing/stfolder.go
@@
-6,22
+6,21
@@
import (
"strings"
common "github.com/iotbzh/xds-common/golib"
"strings"
common "github.com/iotbzh/xds-common/golib"
- "github.com/iotbzh/xds-server/lib/folder"
stconfig "github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/protocol"
)
stconfig "github.com/syncthing/syncthing/lib/config"
"github.com/syncthing/syncthing/lib/protocol"
)
-// F
IXME remove and use an interface on xdsconfig.FolderConfig
+// F
olderChangeArg argument structure used by FolderChange
type FolderChangeArg struct {
ID string
Label string
RelativePath string
SyncThingID string
type FolderChangeArg struct {
ID string
Label string
RelativePath string
SyncThingID string
- ShareRootDir string
}
// FolderLoadFromStConfig Load/Retrieve folder config from syncthing database
}
// FolderLoadFromStConfig Load/Retrieve folder config from syncthing database
-func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error {
+/*
+func (s *SyncThing) FolderLoadFromStConfig(f *[]XdsFolderConfig) error {
defaultSdk := "" // cannot know which was the default sdk
defaultSdk := "" // cannot know which was the default sdk
@@
-41,26
+40,21
@@
func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error {
}
for _, stFld := range stCfg.Folders {
}
for _, stFld := range stCfg.Folders {
- /*
- cliPath := strings.TrimPrefix(stFld.Path, s.conf.FileConf.ShareRootDir)
- if cliPath == "" {
- cliPath = stFld.Path
- }*/
- cliPath := stFld.Path
- *f = append(*f, folder.FolderConfig{
+ *f = append(*f, XdsFolderConfig{
ID: stFld.ID,
Label: stFld.Label,
ID: stFld.ID,
Label: stFld.Label,
- ClientPath: strings.TrimRight(
cli
Path, "/"),
- Type:
folder.
TypeCloudSync,
- Status:
folder.
StatusDisable,
+ ClientPath: strings.TrimRight(
stFld.
Path, "/"),
+ Type:
Xds
TypeCloudSync,
+ Status: StatusDisable,
DefaultSdk: defaultSdk,
DefaultSdk: defaultSdk,
- RootPath: "",
//s.conf.FileConf.ShareRootDir,
- DataCloudSync:
folder.
CloudSyncConfig{SyncThingID: devID},
+ RootPath: "",
+ DataCloudSync:
Xds
CloudSyncConfig{SyncThingID: devID},
})
}
return nil
}
})
}
return nil
}
+*/
// FolderChange is called when configuration has changed
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
// FolderChange is called when configuration has changed
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
@@
-72,16
+66,17
@@
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
return "", err
}
return "", err
}
+ stClientID := f.SyncThingID
// Add new Device if needed
var devID protocol.DeviceID
// Add new Device if needed
var devID protocol.DeviceID
- if err := devID.UnmarshalText([]byte(
f.SyncThing
ID)); err != nil {
+ if err := devID.UnmarshalText([]byte(
stClient
ID)); err != nil {
s.log.Errorf("not a valid device id (err %v)", err)
return "", err
}
newDevice := stconfig.DeviceConfiguration{
DeviceID: devID,
s.log.Errorf("not a valid device id (err %v)", err)
return "", err
}
newDevice := stconfig.DeviceConfiguration{
DeviceID: devID,
- Name:
f.SyncThing
ID,
+ Name:
stClient
ID,
Addresses: []string{"dynamic"},
}
Addresses: []string{"dynamic"},
}
@@
-102,7
+97,7
@@
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
label = strings.Split(id, "/")[0]
}
if id = f.ID; id == "" {
label = strings.Split(id, "/")[0]
}
if id = f.ID; id == "" {
- id =
f.SyncThing
ID[0:15] + "_" + label
+ id =
stClient
ID[0:15] + "_" + label
}
// Resolve local path
}
// Resolve local path
@@
-110,8
+105,6
@@
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
if err != nil {
pathCli = f.RelativePath
}
if err != nil {
pathCli = f.RelativePath
}
- // SEB still need ShareRootDir ? a sup
- // pathCli := filepath.Join(f.ShareRootDir, f.RelativePath)
folder := stconfig.FolderConfiguration{
ID: id,
folder := stconfig.FolderConfiguration{
ID: id,
@@
-145,11
+138,8
@@
func (s *SyncThing) FolderChange(f FolderChangeArg) (string, error) {
}
err = s.ConfigSet(stCfg)
}
err = s.ConfigSet(stCfg)
- if err != nil {
- s.log.Errorln(err)
- }
- return id,
nil
+ return id,
err
}
// FolderDelete is called to delete a folder config
}
// FolderDelete is called to delete a folder config