Documentation
¶
Index ¶
- Constants
- func Init(lg Logger)
- type Tree
- func (tree *Tree) Add(file *File) (newPath string, rterr error)
- func (tree *Tree) ConsumeEvent(event *Event) (err error)
- func (tree *Tree) DiffParents(newPath, oldPath string) (newParents, oldParents string, rterr error)
- func (tree *Tree) GenerateParents(pth string) (parents []string, err error)
- func (tree *Tree) GetFileByID(id string) (*File, error)
- func (tree *Tree) GetFileByPath(path string) (*File, error)
- func (tree *Tree) Print()
- func (tree *Tree) RegisterIDForPath(id, filepath string) error
- func (tree *Tree) Remove(id, oldPath string) (err error)
- func (tree *Tree) Update(newFile *drv.File, regeneratePath bool) (newPath string, rterr error)
- func (tree *Tree) UpdateTree(files []*drv.File) error
Constants ¶
const (
ORPHAN_ROOT = "/drive-lost+found-here/"
)
Variables ¶
This section is empty.
Functions ¶
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 (*Tree) Add ¶
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 ¶
This function consumes a remote event to update the tree
func (*Tree) DiffParents ¶
Diff parents and output strings to be passed to a files update call. Needs the newPath, oldPath and original parents
func (*Tree) GenerateParents ¶
Generate a parents slice from a file path
func (*Tree) GetFileByID ¶
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) RegisterIDForPath ¶
Register a new File with the bare minimum (FileID, name, path and parents)