convert

package
v0.0.0-...-aafedb1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ORPHAN_ROOT = "/drive-lost+found-here/"
)

Variables

This section is empty.

Functions

func Init

func Init(lg Logger)

This function initializes global vars

Types

type Tree

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

This type holds the entire file hierarchy and its equivalent on the local filesystem As you may know, Google Drive doesn't use file paths, so it's difficult to trace a file to it's path here. We want to hace the following info indexed: - Path - FileID So will make two maps, one where the key is the path and another where the key is the fileID. Value is a pointer to File The value of path map will be a double pointer Maps are pointers to allow atomic updates

func NewTree

func NewTree(root string, files []*drv.File) (*Tree, error)

Initialize a new Tree

func (*Tree) Add

func (tree *Tree) Add(file *File) (newPath string, rterr error)

Insert a new file in the tree (both maps). Returns error if that key already exists. Also it generates a path for the file if it doesn't have one. Returns the generated path or the one included on File (a rare case).

func (*Tree) ConsumeEvent

func (tree *Tree) ConsumeEvent(event *Event) (err error)

This function consumes a remote event to update the tree

func (*Tree) DiffParents

func (tree *Tree) DiffParents(newPath, oldPath string) (newParents, oldParents string, rterr error)

Diff parents and output strings to be passed to a files update call. Needs the newPath, oldPath and original parents

func (*Tree) GenerateParents

func (tree *Tree) GenerateParents(pth string) (parents []string, err error)

Generate a parents slice from a file path

func (*Tree) GetFileByID

func (tree *Tree) GetFileByID(id string) (*File, error)

This function takes a file ID and returns a pointer to drv.File or nil if the file doesn't exist

func (*Tree) GetFileByPath

func (tree *Tree) GetFileByPath(path string) (*File, error)

func (*Tree) Print

func (tree *Tree) Print()

func (*Tree) RegisterIDForPath

func (tree *Tree) RegisterIDForPath(id, filepath string) error

Register a new File with the bare minimum (FileID, name, path and parents)

func (*Tree) Remove

func (tree *Tree) Remove(id, oldPath string) (err error)

Remove a file from the trees

func (*Tree) Update

func (tree *Tree) Update(newFile *drv.File, regeneratePath bool) (newPath string, rterr error)

Update a file in the tree. Optionally generate a new path which will be returned. If the requested file doesn't exist on the tree, an error will be returned

func (*Tree) UpdateTree

func (tree *Tree) UpdateTree(files []*drv.File) error

Update maps on the Tree. The update is atomic, so if an error occurs the maps are left untouched

Jump to

Keyboard shortcuts

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