// Add traverse VTree to locate path parent dir and add a new vnode.
Add traverse VTree to locate path parent dir and add a new vnode.
// Add traverse VTree to locate path parent dir and add a new vnode .
func (vt *VTree) Add(path string) error {
	vt.Lock()
	defer vt.Unlock()
	dir := filepath.Dir(path)
	vn, err := vt.Find(dir)
	if err != nil {
		return err
	}
	n := vn.NewVNode(path)
	isDir, err := utils.IsDir(path)
	if err != nil {
		return err
	}
	if isDir {
		n.SetAsDir()
		n.PopulateNodes(db.Sources{}, true)
	} else {
		n.SetAsFile()
		n.SaveSource()
	}
	vt.PushToState(path, AddedOp)
	return nil
}
func ( vt * VTree ) Add ( path string ) error { vt . Lock ( ) defer vt . Unlock ( ) dir := filepath . Dir ( path ) vn , err := vt . Find ( dir ) if err != nil { return err } n := vn . NewVNode ( path ) isDir , err := utils . IsDir ( path ) if err != nil { return err } if isDir { n . SetAsDir ( ) n . PopulateNodes ( db . Sources { } , true ) } else { n . SetAsFile ( ) n . SaveSource ( ) } vt . PushToState ( path , AddedOp ) return nil }
Add traverse VTree to locate path parent dir and add a new vnode.
Add traverse VTree to locate path parent dir and add a new vnode .
// Read file content and upload