Documentation ¶
Index ¶
- func AuthorizeApp(tokenLocation string)
- func CreateFile(service *drive.Service, local string, parentID string) (string, error)
- func CreateFolder(service *drive.Service, remote string, parentID ...string) (string, error)
- func DebounceEvents(input, output chan Event)
- func DeleteFileOrFolder(service *drive.Service, id string) error
- func ExecuteEvents(state *State)
- func GetDriveService(tokenLocation string) *drive.Service
- func QueryAllContents(service *drive.Service) ([]*drive.File, error)
- func QueryFileID(service *drive.Service, local string) (string, error)
- func RenameFileOrFolder(service *drive.Service, info RenameInfo) (*drive.File, error)
- func UpdateFile(service *drive.Service, local, fileID string) (*drive.File, error)
- func WatchLoop(state *State)
- type Event
- type EventCategory
- type IDKey
- type PathID
- type RenameInfo
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthorizeApp ¶
func AuthorizeApp(tokenLocation string)
AuthorizeApp triggers the OAuth 2.0 web authentication for Piledriver
func CreateFile ¶
CreateFile creates the file in drive, with the parent directory specified by parentID and filename same as input file. It does NOT check for the validity of parentID. If queue is nil, the Do() will be executed in this method itself
func CreateFolder ¶
CreateFolder creates a folder in drive, with a parent directory specified by parentID If no parent directories are specified, then it is not set
func DebounceEvents ¶
func DebounceEvents(input, output chan Event)
DebounceEvents removes identical events less than some threshold.
func DeleteFileOrFolder ¶
DeleteFileOrFolder deletes the file (or folder) in the drive with the givwn ID
func ExecuteEvents ¶
func ExecuteEvents(state *State)
ExecuteEvents takes a channel Events and executes them
func GetDriveService ¶
func GetDriveService(tokenLocation string) *drive.Service
GetDriveService reads the token from the file denoted by tokenLocation and then returns the Google Drive service. If it cannot find the token file, it errors out and stops the program.
func QueryAllContents ¶
func QueryAllContents(service *drive.Service) ([]*drive.File, error)
QueryAllContents returns a list of all the files uploaded to Drive by Piledriver that were not trashed by the user
func QueryFileID ¶
QueryFileID queries Google drive for the id of a file (or folder) with the givwn path If the file is found, then err is nil
func RenameFileOrFolder ¶
func RenameFileOrFolder(service *drive.Service, info RenameInfo) (*drive.File, error)
RenameFileOrFolder models the UNIX mv (1) command for Google Drive
func UpdateFile ¶
UpdateFile updates the file to the new contents
Types ¶
type Event ¶
type Event struct { OldPath string Path string Category EventCategory IDMap map[IDKey]string Timestamp time.Time }
Event is the internal representation of file watcher events
type EventCategory ¶
type EventCategory uint
EventCategory denotes the type of event that has been detected
const ( FileCreated EventCategory = iota DirectoryCreated FileDeleted DirectoryDeleted FileRenamed DirectoryRenamed FileWritten MaxEventCategory )
Various types of event categories
type PathID ¶
type PathID struct {
// contains filtered or unexported fields
}
PathID contains the path and the id returned for it
type RenameInfo ¶
RenameInfo contains fields necessary for renaming a file/folder
type State ¶
type State struct { Config config.Config LogFilePath string FileEvents chan Event DebouncedEvents chan Event // contains filtered or unexported fields }
State holds global state info for the program
func (*State) InitService ¶
InitService initializes the service field
func (*State) InitWatcher ¶
func (state *State) InitWatcher()
InitWatcher initializes the watcher field