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 RegisterEventChange(cb *EventCB, data *EventCBData) error // Request events registration (sent through WS)
34 UnRegisterEventChange() error // Un-register events
35 Sync() error // Force folder files synchronization
36 IsInSync() (bool, error) // Check if folder files are in-sync
39 // FolderConfig is the config for one folder
40 type FolderConfig struct {
42 Label string `json:"label"`
43 ClientPath string `json:"path"`
44 Type FolderType `json:"type"`
45 Status string `json:"status"`
46 IsInSync bool `json:"isInSync"`
47 DefaultSdk string `json:"defaultSdk"`
49 // Not exported fields from REST API point of view
50 RootPath string `json:"-"`
52 // FIXME: better to define an equivalent to union data and then implement
53 // UnmarshalJSON/MarshalJSON to decode/encode according to Type value
54 // Data interface{} `json:"data"`
56 // Specific data depending on which Type is used
57 DataPathMap PathMapConfig `json:"dataPathMap,omitempty"`
58 DataCloudSync CloudSyncConfig `json:"dataCloudSync,omitempty"`
61 // PathMapConfig Path mapping specific data
62 type PathMapConfig struct {
63 ServerPath string `json:"serverPath"`
65 // Don't keep temporary file name (IOW we don't want to save it and reuse it)
66 CheckFile string `json:"checkFile" xml:"-"`
67 CheckContent string `json:"checkContent" xml:"-"`
70 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
71 type CloudSyncConfig struct {
72 SyncThingID string `json:"syncThingID"`