- // (except if status is ErrorConfig)
- // TODO: add cache to avoid multiple requests on startup
- if f.fConfig.Status != xsapiv1.StatusErrorConfig {
- id, err := f.st.FolderChange(f.fConfig)
- if err != nil {
- return nil, err
- }
+ _, err := f.st.FolderChange(f.fConfig)
+ if err != nil {
+ return nil, err
+ }
+
+ // Use Setup function to setup remains fields
+ return f.Setup(f.fConfig)
+}
+
+// Setup Setup local project config
+func (f *STFolder) Setup(fld xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
+
+ var err error
+
+ // Update folder Config
+ f.fConfig = fld
+
+ // Retrieve Syncthing folder config
+ f.stfConfig, err = f.st.FolderConfigGet(f.fConfig.ID)
+ if err != nil {
+ f.fConfig.Status = xsapiv1.StatusErrorConfig
+ return nil, err
+ }