2 * Copyright (C) 2017 "IoT.bzh"
3 * Author Sebastien Douheret <sebastien@iot.bzh>
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
21 "github.com/iotbzh/xds-server/lib/xsapiv1"
22 uuid "github.com/satori/go.uuid"
25 // IFOLDER interface implementation for disabled Syncthing folders
26 // It's a "fallback" interface used to keep syncthing folders config even
27 // when syncthing is not running.
30 type STFolderDisable struct {
32 config xsapiv1.FolderConfig
35 // NewFolderSTDisable Create a new instance of STFolderDisable
36 func NewFolderSTDisable(ctx *Context) *STFolderDisable {
44 func (f *STFolderDisable) NewUID(suffix string) string {
45 uuid := uuid.NewV1().String()
53 func (f *STFolderDisable) Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
55 f.config.Status = xsapiv1.StatusDisable
56 f.config.IsInSync = false
60 // GetConfig Get public part of folder config
61 func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig {
65 // GetFullPath returns the full path of a directory (from server POV)
66 func (f *STFolderDisable) GetFullPath(dir string) string {
70 // ConvPathCli2Svr Convert path from Client to Server
71 func (f *STFolderDisable) ConvPathCli2Svr(s string) string {
75 // ConvPathSvr2Cli Convert path from Server to Client
76 func (f *STFolderDisable) ConvPathSvr2Cli(s string) string {
81 func (f *STFolderDisable) Remove() error {
85 // Update update some fields of a folder
86 func (f *STFolderDisable) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
90 // RegisterEventChange requests registration for folder change event
91 func (f *STFolderDisable) RegisterEventChange(cb *FolderEventCB, data *FolderEventCBData) error {
95 // UnRegisterEventChange remove registered callback
96 func (f *STFolderDisable) UnRegisterEventChange() error {
100 // Sync Force folder files synchronization
101 func (f *STFolderDisable) Sync() error {
105 // IsInSync Check if folder files are in-sync
106 func (f *STFolderDisable) IsInSync() (bool, error) {