Beispiel #1
0
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
}
Beispiel #2
0
// Make some changes in the test zx tree, another version.
//	- Remove /2
//	- Create /2/n2
//	- Truncate /1
func MkZXChgs2(t Fataler, fs zx.RWTree) {
	if err := <-fs.Remove("/2"); err != nil {
		t.Fatalf("rm: %s", err)
	}
	<-fs.Mkdir("/2", zx.Dir{"mode": "0750"})
	if err := <-fs.Mkdir("/2/n2", zx.Dir{"mode": "0750"}); err != nil {
		t.Fatalf("mkdir: %s", err)
	}
	TouchZX(fs, "/2/n2")
	TouchZX(fs, "/2")
	if err := <-fs.Wstat("/1", zx.Dir{"size": "50"}); err != nil {
		t.Fatalf("truncate: %s", err)
	}
	TouchZX(fs, "/1")
}
Beispiel #3
0
// Make some changes in the test zx tree.
//	- Touch /a/a1
//	- Chmod /a/a2
//	- Remove /a/b/c /a/b/c/c3
//	- Create /a/n /a/n/m /a/n/m/m1
func MkZXChgs(t Fataler, fs zx.RWTree) {
	TouchZX(fs, "/a/a1")
	if err := <- fs.Wstat("/a/a2", zx.Dir{"mode": "0750"}); err != nil {
		t.Fatalf("chmod: %s", err)
	}
	if err := <-fs.RemoveAll("/a/b/c"); err != nil {
		t.Fatalf("rm: %s", err)
	}
	<-fs.Mkdir("/a", zx.Dir{"mode": "0750"})
	<-fs.Mkdir("/a/n", zx.Dir{"mode": "0750"})
	if err := <-fs.Mkdir("/a/n/m", zx.Dir{"mode": "0750"}); err != nil {
		t.Fatalf("mkdir: %s", err)
	}
	err := zx.PutAll(fs, "/a/n/m/m1", zx.Dir{"mode": "0640"}, []byte("a new file\n"))
	if err != nil {
		t.Fatalf("new file: %s", err)
	}
	TouchZX(fs, "/a/n/m/m1")
	TouchZX(fs, "/a/n/m")
	TouchZX(fs, "/a/n")
	TouchZX(fs, "/a")
}
Beispiel #4
0
func rmkdir(t Fataler, fs zx.RWTree, fname string) {
	<-fs.Mkdir(fname, zx.Dir{"mode": "0755"})
}