aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/folder-st-disable.go
blob: c52854d78df5d61dc5140aca64a7bd6e0468c953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 * Copyright (C) 2017 "IoT.bzh"
 * Author Sebastien Douheret <sebastien@iot.bzh>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package xdsserver

import (
	"github.com/iotbzh/xds-server/lib/xsapiv1"
	uuid "github.com/satori/go.uuid"
)

// IFOLDER interface implementation for disabled Syncthing folders
// It's a "fallback" interface used to keep syncthing folders config even
// when syncthing is not running.

// STFolderDisable .
type STFolderDisable struct {
	*Context
	fConfig xsapiv1.FolderConfig
}

// NewFolderSTDisable Create a new instance of STFolderDisable
func NewFolderSTDisable(ctx *Context) *STFolderDisable {
	f := STFolderDisable{
		Context: ctx,
	}
	return &f
}

// NewUID Get a UUID
func (f *STFolderDisable) NewUID(suffix string) string {
	uuid := uuid.NewV1().String()
	if len(suffix) > 0 {
		uuid += "_" + suffix
	}
	return uuid
}

// Add a new folder
func (f *STFolderDisable) Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
	return f.Setup(cfg)
}

// Setup Setup local project config
func (f *STFolderDisable) Setup(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
	f.fConfig = cfg
	f.fConfig.Status = xsapiv1.StatusDisable
	f.fConfig.IsInSync = false
	return &f.fConfig, nil
}

// GetConfig Get public part of folder config
func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig {
	return f.fConfig
}

// GetFullPath returns the full path of a directory (from server POV)
func (f *STFolderDisable) GetFullPath(dir string) string {
	return ""
}

// ConvPathCli2Svr Convert path from Client to Server
func (f *STFolderDisable) ConvPathCli2Svr(s string) string {
	return ""
}

// ConvPathSvr2Cli Convert path from Server to Client
func (f *STFolderDisable) ConvPathSvr2Cli(s string) string {
	return ""
}

// Remove a folder
func (f *STFolderDisable) Remove() error {
	return nil
}

// Update update some fields of a folder
func (f *STFolderDisable) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
	return nil, nil
}

// Sync Force folder files synchronization
func (f *STFolderDisable) Sync() error {
	return nil
}

// IsInSync Check if folder files are in-sync
func (f *STFolderDisable) IsInSync() (bool, error) {
	return false, nil
}