2 * Copyright (C) 2017-2018 "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 "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/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 fConfig 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) {
57 // Setup Setup local project config
58 func (f *STFolderDisable) Setup(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
60 f.fConfig.Status = xsapiv1.StatusDisable
61 f.fConfig.IsInSync = false
62 return &f.fConfig, nil
65 // GetConfig Get public part of folder config
66 func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig {
70 // GetFullPath returns the full path of a directory (from server POV)
71 func (f *STFolderDisable) GetFullPath(dir string) string {
75 // ConvPathCli2Svr Convert path from Client to Server
76 func (f *STFolderDisable) ConvPathCli2Svr(s string) string {
80 // ConvPathSvr2Cli Convert path from Server to Client
81 func (f *STFolderDisable) ConvPathSvr2Cli(s string) string {
86 func (f *STFolderDisable) Remove() error {
90 // Update update some fields of a folder
91 func (f *STFolderDisable) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
95 // Sync Force folder files synchronization
96 func (f *STFolderDisable) Sync() error {
100 // IsInSync Check if folder files are in-sync
101 func (f *STFolderDisable) IsInSync() (bool, error) {