3 // FolderType definition
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 Remove() error // Remove a folder
31 RegisterEventChange(cb *EventCB, data *EventCBData) error // Request events registration (sent through WS)
32 UnRegisterEventChange() error // Un-register events
33 Sync() error // Force folder files synchronization
34 IsInSync() (bool, error) // Check if folder files are in-sync
37 // FolderConfig is the config for one folder
38 type FolderConfig struct {
40 Label string `json:"label"`
41 ClientPath string `json:"path"`
42 Type FolderType `json:"type"`
43 Status string `json:"status"`
44 IsInSync bool `json:"isInSync"`
45 DefaultSdk string `json:"defaultSdk"`
47 // Not exported fields from REST API point of view
48 RootPath string `json:"-"`
50 // FIXME: better to define an equivalent to union data and then implement
51 // UnmarshalJSON/MarshalJSON to decode/encode according to Type value
52 // Data interface{} `json:"data"`
54 // Specific data depending on which Type is used
55 DataPathMap PathMapConfig `json:"dataPathMap,omitempty"`
56 DataCloudSync CloudSyncConfig `json:"dataCloudSync,omitempty"`
59 // PathMapConfig Path mapping specific data
60 type PathMapConfig struct {
61 ServerPath string `json:"serverPath"`
64 // CloudSyncConfig CloudSync (AKA Syncthing) specific data
65 type CloudSyncConfig struct {
66 SyncThingID string `json:"syncThingID"`
67 BuilderSThgID string `json:"builderSThgID"`