3 // FolderType definition
7 TypePathMap = "PathMap"
8 TypeCloudSync = "CloudSync"
12 // Folder Status definition
14 StatusErrorConfig = "ErrorConfig"
15 StatusDisable = "Disable"
16 StatusEnable = "Enable"
18 StatusSyncing = "Syncing"
21 type EventCBData map[string]interface{}
22 type EventCB func(cfg *FolderConfig, data *EventCBData)
24 // IFOLDER Folder interface
25 type IFOLDER interface {
26 NewUID(suffix string) string // Get a new folder UUID
27 Add(cfg FolderConfig) (*FolderConfig, error) // Add a new folder
28 GetConfig() FolderConfig // Get folder public configuration
29 GetFullPath(dir string) string // Get folder full path
30 ConvPathCli2Svr(s string) string // Convert path from Client to Server
31 ConvPathSvr2Cli(s string) string // Convert path from Server to Client
32 Remove() error // Remove a folder
33 Update(cfg FolderConfig) (*FolderConfig, error) // Update a new folder
34 RegisterEventChange(cb *EventCB, data *EventCBData) error // Request events registration (sent through WS)
35 UnRegisterEventChange() error // Un-register events
36 Sync() error // Force folder files synchronization
37 IsInSync() (bool, error) // Check if folder files are in-sync
40 // FolderConfig is the config for one folder
41 type FolderConfig struct {
43 Label string `json:"label"`
44 ClientPath string `json:"path"`
45 Type FolderType `json:"type"`
46 Status string `json:"status"`
47 IsInSync bool `json:"isInSync"`
48 DefaultSdk string `json:"defaultSdk"`
49 ClientData string `json:"clientData"` // free form field that can used by client
51 // Not exported fields from REST API point of view
52 RootPath string `json:"-"`
54 // FIXME: better to define an equivalent to union data and then implement
55 // UnmarshalJSON/MarshalJSON to decode/encode according to Type value
56 // Data interface{} `json:"data"`
58 // Specific data depending on which Type is used
59 DataPathMap PathMapConfig `json:"dataPathMap,omitempty"`
60 DataCloudSync CloudSyncConfig `json:"dataCloudSync,omitempty"`
63 // FolderConfigUpdatableFields List fields that can be updated using Update function
64 var FolderConfigUpdatableFields = []string{
65 "Label", "DefaultSdk", "ClientData",
68 // PathMapConfig Path mapping specific data
69 type PathMapConfig struct {
70 ServerPath string `json:"serverPath"`
72 // Don't keep temporary file name (IOW we don't want to save it and reuse it)
73 CheckFile string `json:"checkFile" xml:"-"`
74 CheckContent string `json:"checkContent" xml:"-"`
77 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
78 type CloudSyncConfig struct {
79 SyncThingID string `json:"syncThingID"`