func (ch Chg) applyData(lfs zx.RWTree, rfs zx.Tree) error { nd := ch.D.UsrAttrs() for _, k := range ignoredPutAttrs { delete(nd, k) } datc := rfs.Get(ch.D["path"], 0, zx.All, "") dc := lfs.Put(ch.D["path"], nd, 0, datc, "") <-dc return cerror(dc) }
func (ch Chg) applyAdd(lfs zx.RWTree, rfs zx.Tree, pred string, ec chan<- error) error { var err error gc := rfs.FindGet(ch.D["path"], pred, "", "", 0) for g := range gc { dprintf("get %s\n", g) d := g.Dir if d == nil { break } for _, k := range ignoredPutAttrs { delete(d, k) } if d["err"] != "" { e := errors.New(d["err"]) perr(ec, e) dprintf("%s: %s\n", d["path"], d["err"]) if err == nil { err = e } continue } if g.Datac == nil && d["type"] != "d" { g.Datac = nchan.Null } if d["type"] == "d" { e := <-lfs.Mkdir(d["path"], d) if e != nil { perr(ec, e) if err == nil { err = e } } continue } dc := lfs.Put(d["path"], d, 0, g.Datac, "") <-dc if e := cerror(dc); e != nil { dprintf("%s: put: %s\n", d["path"], e) perr(ec, e) if err == nil { err = e } } } close(gc) if e := cerror(gc); e != nil { dprintf("get: %s\n", e) perr(ec, e) if err == nil { err = e } } return err }