st

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2017 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventFolderCompletion string = "FolderCompletion"
	EventFolderSummary    string = "FolderSummary"
	EventFolderPaused     string = "FolderPaused"
	EventFolderResumed    string = "FolderResumed"
	EventFolderErrors     string = "FolderErrors"
	EventStateChanged     string = "StateChanged"
)

Variables

View Source
var EventsAll string = EventFolderCompletion + "|" +
	EventFolderSummary + "|" +
	EventFolderPaused + "|" +
	EventFolderResumed + "|" +
	EventFolderErrors + "|" +
	EventStateChanged

Functions

This section is empty.

Types

type Event

type Event struct {
	Type string            `json:"type"`
	Time time.Time         `json:"time"`
	Data map[string]string `json:"data"`
}

type Events

type Events struct {
	MonitorTime time.Duration
	Debug       bool
	// contains filtered or unexported fields
}

Events .

func (*Events) Register

func (e *Events) Register(evName string, cb EventsCB, filterID string, data *EventsCBData) (int, error)

Register Add a listener on an event

func (*Events) Start

func (e *Events) Start() error

Start starts event monitoring loop

func (*Events) Stop

func (e *Events) Stop()

Stop stops event monitoring loop

func (*Events) UnRegister

func (e *Events) UnRegister(evName string, id int) error

UnRegister Remove a listener event

type EventsCB

type EventsCB func(ev Event, cbData *EventsCBData)

type EventsCBData

type EventsCBData map[string]interface{}

type ExitChan

type ExitChan struct {
	// contains filtered or unexported fields
}

ExitChan Channel used for process exit

type FolderStatus

type FolderStatus struct {
	GlobalFiles       int   `json:"globalFiles"`
	GlobalDirectories int   `json:"globalDirectories"`
	GlobalSymlinks    int   `json:"globalSymlinks"`
	GlobalDeleted     int   `json:"globalDeleted"`
	GlobalBytes       int64 `json:"globalBytes"`

	LocalFiles       int   `json:"localFiles"`
	LocalDirectories int   `json:"localDirectories"`
	LocalSymlinks    int   `json:"localSymlinks"`
	LocalDeleted     int   `json:"localDeleted"`
	LocalBytes       int64 `json:"localBytes"`

	NeedFiles       int   `json:"needFiles"`
	NeedDirectories int   `json:"needDirectories"`
	NeedSymlinks    int   `json:"needSymlinks"`
	NeedDeletes     int   `json:"needDeletes"`
	NeedBytes       int64 `json:"needBytes"`

	InSyncFiles int   `json:"inSyncFiles"`
	InSyncBytes int64 `json:"inSyncBytes"`

	State        string    `json:"state"`
	StateChanged time.Time `json:"stateChanged"`

	Sequence int64 `json:"sequence"`

	IgnorePatterns bool `json:"ignorePatterns"`
}

FolderStatus Information about the current status of a folder.

type STEvent

type STEvent struct {
	// Per-subscription sequential event ID. Named "id" for backwards compatibility with the REST API
	SubscriptionID int `json:"id"`
	// Global ID of the event across all subscriptions
	GlobalID int                    `json:"globalID"`
	Time     time.Time              `json:"time"`
	Type     string                 `json:"type"`
	Data     map[string]interface{} `json:"data"`
}

type STFolder

type STFolder struct {
	// contains filtered or unexported fields
}

STFolder .

func (*STFolder) Add

Add a new folder

func (*STFolder) ConvPathCli2Svr

func (f *STFolder) ConvPathCli2Svr(s string) string

ConvPathCli2Svr Convert path from Client to Server

func (*STFolder) ConvPathSvr2Cli

func (f *STFolder) ConvPathSvr2Cli(s string) string

ConvPathSvr2Cli Convert path from Server to Client

func (*STFolder) GetConfig

func (f *STFolder) GetConfig() folder.FolderConfig

GetConfig Get public part of folder config

func (*STFolder) GetFullPath

func (f *STFolder) GetFullPath(dir string) string

GetFullPath returns the full path of a directory (from server POV)

func (*STFolder) IsInSync

func (f *STFolder) IsInSync() (bool, error)

IsInSync Check if folder files are in-sync

func (*STFolder) NewUID

func (f *STFolder) NewUID(suffix string) string

NewUID Get a UUID

func (*STFolder) RegisterEventChange

func (f *STFolder) RegisterEventChange(cb *folder.EventCB, data *folder.EventCBData) error

RegisterEventChange requests registration for folder event change

func (*STFolder) Remove

func (f *STFolder) Remove() error

Remove a folder

func (*STFolder) Sync

func (f *STFolder) Sync() error

Sync Force folder files synchronization

func (*STFolder) UnRegisterEventChange

func (f *STFolder) UnRegisterEventChange() error

UnRegisterEventChange remove registered callback

type SyncThing

type SyncThing struct {
	BaseURL   string
	APIKey    string
	Home      string
	STCmd     *exec.Cmd
	STICmd    *exec.Cmd
	MyID      string
	Connected bool

	Events *Events
	// contains filtered or unexported fields
}

SyncThing .

func NewSyncThing

func NewSyncThing(conf *xdsconfig.Config, log *logrus.Logger) *SyncThing

NewSyncThing creates a new instance of Syncthing

func (*SyncThing) ConfigGet

func (s *SyncThing) ConfigGet() (config.Configuration, error)

ConfigGet returns the current Syncthing configuration

func (*SyncThing) ConfigSet

func (s *SyncThing) ConfigSet(cfg config.Configuration) error

ConfigSet set Syncthing configuration

func (*SyncThing) Connect

func (s *SyncThing) Connect() error

Connect Establish HTTP connection with Syncthing

func (*SyncThing) FolderChange

func (s *SyncThing) FolderChange(f folder.FolderConfig) (string, error)

FolderChange is called when configuration has changed

func (*SyncThing) FolderConfigGet

func (s *SyncThing) FolderConfigGet(folderID string) (config.FolderConfiguration, error)

FolderConfigGet Returns the configuration of a specific folder

func (*SyncThing) FolderDelete

func (s *SyncThing) FolderDelete(id string) error

FolderDelete is called to delete a folder config

func (*SyncThing) FolderLoadFromStConfig

func (s *SyncThing) FolderLoadFromStConfig(f *[]folder.FolderConfig) error

FolderLoadFromStConfig Load/Retrieve folder config from syncthing database

func (*SyncThing) FolderScan

func (s *SyncThing) FolderScan(folderID string, subpath string) error

FolderScan Request immediate folder scan. Scan all folders if folderID param is empty

func (*SyncThing) FolderStatus

func (s *SyncThing) FolderStatus(folderID string) (*FolderStatus, error)

FolderStatus Returns all information about the current

func (*SyncThing) IDGet

func (s *SyncThing) IDGet() (string, error)

IDGet returns the Syncthing ID of Syncthing instance running locally

func (*SyncThing) IsConfigInSync

func (s *SyncThing) IsConfigInSync() (bool, error)

IsConfigInSync Returns true if configuration is in sync

func (*SyncThing) IsFolderInSync

func (s *SyncThing) IsFolderInSync(folderID string) (bool, error)

IsFolderInSync Returns true when folder is in sync

func (*SyncThing) NewEventListener

func (s *SyncThing) NewEventListener() *Events

NewEventListener Create a new instance of Event listener

func (*SyncThing) NewFolderST

func (s *SyncThing) NewFolderST(gc *xdsconfig.Config) *STFolder

NewFolderST Create a new instance of STFolder

func (*SyncThing) Start

func (s *SyncThing) Start() (*exec.Cmd, error)

Start Starts syncthing process

func (*SyncThing) StartInotify

func (s *SyncThing) StartInotify() (*exec.Cmd, error)

StartInotify Starts syncthing-inotify process

func (*SyncThing) Stop

func (s *SyncThing) Stop()

Stop Stops syncthing process

func (*SyncThing) StopInotify

func (s *SyncThing) StopInotify()

StopInotify Stops syncthing process

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL