Refit source files to have a public xs-apiv1 lib package.
[src/xds/xds-server.git] / lib / syncthing / stfolder.go
index 70ac70a..1a5a7ec 100644 (file)
@@ -6,13 +6,13 @@ import (
        "path/filepath"
        "strings"
 
-       "github.com/iotbzh/xds-server/lib/folder"
-       "github.com/syncthing/syncthing/lib/config"
+       "github.com/iotbzh/xds-server/lib/xsapiv1"
+       stconfig "github.com/syncthing/syncthing/lib/config"
        "github.com/syncthing/syncthing/lib/protocol"
 )
 
 // FolderLoadFromStConfig Load/Retrieve folder config from syncthing database
-func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error {
+func (s *SyncThing) FolderLoadFromStConfig(f *[]xsapiv1.FolderConfig) error {
 
        defaultSdk := "" // cannot know which was the default sdk
 
@@ -32,19 +32,19 @@ func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error {
        }
 
        for _, stFld := range stCfg.Folders {
-               cliPath := strings.TrimPrefix(stFld.RawPath, s.conf.FileConf.ShareRootDir)
+               cliPath := strings.TrimPrefix(stFld.Path, s.conf.FileConf.ShareRootDir)
                if cliPath == "" {
-                       cliPath = stFld.RawPath
+                       cliPath = stFld.Path
                }
-               *f = append(*f, folder.FolderConfig{
+               *f = append(*f, xsapiv1.FolderConfig{
                        ID:            stFld.ID,
                        Label:         stFld.Label,
                        ClientPath:    strings.TrimRight(cliPath, "/"),
-                       Type:          folder.TypeCloudSync,
-                       Status:        folder.StatusDisable,
+                       Type:          xsapiv1.TypeCloudSync,
+                       Status:        xsapiv1.StatusDisable,
                        DefaultSdk:    defaultSdk,
                        RootPath:      s.conf.FileConf.ShareRootDir,
-                       DataCloudSync: folder.CloudSyncConfig{SyncThingID: devID},
+                       DataCloudSync: xsapiv1.CloudSyncConfig{SyncThingID: devID},
                })
        }
 
@@ -52,7 +52,7 @@ func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error {
 }
 
 // FolderChange is called when configuration has changed
-func (s *SyncThing) FolderChange(f folder.FolderConfig) (string, error) {
+func (s *SyncThing) FolderChange(f xsapiv1.FolderConfig) (string, error) {
 
        // Get current config
        stCfg, err := s.ConfigGet()
@@ -69,7 +69,7 @@ func (s *SyncThing) FolderChange(f folder.FolderConfig) (string, error) {
                return "", err
        }
 
-       newDevice := config.DeviceConfiguration{
+       newDevice := stconfig.DeviceConfiguration{
                DeviceID:  devID,
                Name:      stClientID,
                Addresses: []string{"dynamic"},
@@ -95,22 +95,22 @@ func (s *SyncThing) FolderChange(f folder.FolderConfig) (string, error) {
                id = stClientID[0:15] + "_" + label
        }
 
-       folder := config.FolderConfiguration{
-               ID:      id,
-               Label:   label,
-               RawPath: filepath.Join(s.conf.FileConf.ShareRootDir, f.ClientPath),
+       folder := stconfig.FolderConfiguration{
+               ID:    id,
+               Label: label,
+               Path:  filepath.Join(s.conf.FileConf.ShareRootDir, f.ClientPath),
        }
 
        if s.conf.FileConf.SThgConf.RescanIntervalS > 0 {
                folder.RescanIntervalS = s.conf.FileConf.SThgConf.RescanIntervalS
        }
 
-       folder.Devices = append(folder.Devices, config.FolderDeviceConfiguration{
+       folder.Devices = append(folder.Devices, stconfig.FolderDeviceConfiguration{
                DeviceID: newDevice.DeviceID,
        })
 
        found = false
-       var fld config.FolderConfiguration
+       var fld stconfig.FolderConfiguration
        for _, fld = range stCfg.Folders {
                if folder.ID == fld.ID {
                        fld = folder
@@ -155,8 +155,8 @@ func (s *SyncThing) FolderDelete(id string) error {
 }
 
 // FolderConfigGet Returns the configuration of a specific folder
-func (s *SyncThing) FolderConfigGet(folderID string) (config.FolderConfiguration, error) {
-       fc := config.FolderConfiguration{}
+func (s *SyncThing) FolderConfigGet(folderID string) (stconfig.FolderConfiguration, error) {
+       fc := stconfig.FolderConfiguration{}
        if folderID == "" {
                return fc, fmt.Errorf("folderID not set")
        }