Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Import renames #15

Closed
wants to merge 4 commits into from

3 participants

@cloudhead

Rename doozerd imports to point to soundcloud fork.

xla and others added some commits
@xla xla Reimplement Walk to expect WalkFunc
* filepath.Walk was recently changed [https://groups.google.com/group/golang-nuts/msg/e304dd9cf196a218]
* Remove Visitor interface
* Introduce WalkFunc type
* Align WalkFunc with path/filepath.WalkFunc
* Fix Walk usage in find cmd
ceb75f6
@xla xla Change Walk to match filepath.Walk 634a732
@kesselborn kesselborn rename pretty.go -> pretty b2b8f82
@cloudhead cloudhead Change imports to soundcloud repo 6904e2f
@cloudhead cloudhead closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2012
  1. @xla

    Reimplement Walk to expect WalkFunc

    xla authored
    * filepath.Walk was recently changed [https://groups.google.com/group/golang-nuts/msg/e304dd9cf196a218]
    * Remove Visitor interface
    * Introduce WalkFunc type
    * Align WalkFunc with path/filepath.WalkFunc
    * Fix Walk usage in find cmd
  2. @xla

    Change Walk to match filepath.Walk

    xla authored
Commits on Mar 29, 2012
  1. @kesselborn

    rename pretty.go -> pretty

    kesselborn authored
Commits on May 3, 2012
  1. @cloudhead
This page is out of date. Refresh to see the latest.
View
2  Makefile
@@ -1,6 +1,6 @@
include Make.inc
-TARG=github.com/ha/doozer
+TARG=github.com/soundcloud/doozer
GOFILES=\
conn.go\
err.go\
View
2  cmd/doozer/doozer.go
@@ -3,7 +3,7 @@ package main
import (
"flag"
"fmt"
- "github.com/ha/doozer"
+ "github.com/soundcloud/doozer"
"os"
"reflect"
"sort"
View
34 cmd/doozer/find.go
@@ -2,7 +2,7 @@ package main
import (
"fmt"
- "github.com/ha/doozer"
+ "github.com/soundcloud/doozer"
"os"
)
@@ -25,33 +25,15 @@ func find(path string) {
}
}
- v := make(vis)
- errs := make(chan error)
- go func() {
- doozer.Walk(c, *rrev, path, v, errs)
- close(v)
- }()
-
- for {
- select {
- case path, ok := <-v:
- if !ok {
- return
- }
- fmt.Println(path)
- case err := <-errs:
+ v := func(path string, f *doozer.FileInfo, e error) (err error) {
+ if e != nil {
fmt.Fprintln(os.Stderr, err)
+ return
}
- }
-}
-type vis chan string
+ fmt.Println(path)
-func (v vis) VisitDir(path string, f *doozer.FileInfo) bool {
- v <- path
- return true
-}
-
-func (v vis) VisitFile(path string, f *doozer.FileInfo) {
- v <- path
+ return nil
+ }
+ doozer.Walk(c, *rrev, path, v)
}
View
3  conn.go
@@ -4,8 +4,7 @@ import (
"code.google.com/p/goprotobuf/proto"
"encoding/binary"
"errors"
- "github.com/kr/pretty.go"
-
+ "github.com/kr/pretty"
"io"
"log"
"math/rand"
View
4 dist.sh
@@ -11,8 +11,8 @@ cat <<end >$base/README
This is the command line client for Doozer,
a consistent, fault-tolerant data store.
-See http://github.com/ha/doozer
-and http://github.com/ha/doozerd
+See http://github.com/soundcloud/doozer
+and http://github.com/soundcloud/doozerd
end
file=$base-$GOOS-$GOARCH.tar
tar cf $file $base
View
2  file.go
@@ -23,3 +23,5 @@ func basename(path string) string {
}
return path
}
+
+type WalkFunc func(string, *FileInfo, error) error
View
42 walk.go
@@ -1,42 +1,46 @@
package doozer
-type Visitor interface {
- VisitDir(path string, f *FileInfo) bool
- VisitFile(path string, f *FileInfo)
-}
+import (
+ "path/filepath"
+)
// Walk walks the file tree in revision rev, rooted at root,
// analogously to Walk in package path/filepath.
-func Walk(c *Conn, rev int64, root string, v Visitor, errors chan<- error) {
+func Walk(c *Conn, rev int64, root string, v WalkFunc) error {
f, err := c.Statinfo(rev, root)
if err != nil {
- if errors != nil {
- errors <- err
- }
- return
+ v(root, f, err)
+ return err
}
- walk(c, rev, root, f, v, errors)
+ return walk(c, rev, root, f, v)
}
-func walk(c *Conn, r int64, path string, f *FileInfo, v Visitor, errors chan<- error) {
- if !f.IsDir {
- v.VisitFile(path, f)
+func walk(c *Conn, r int64, path string, f *FileInfo, v WalkFunc) (err error) {
+ verr := v(path, f, nil)
+ if !f.IsDir || verr == filepath.SkipDir {
return
}
-
- if !v.VisitDir(path, f) {
- return
+ if verr != nil {
+ return err
}
list, err := c.Getdirinfo(path, r, 0, -1)
- if err != nil && errors != nil {
- errors <- err
+ if err != nil {
+ verr = v(path, f, err)
+ if verr != nil {
+ return err
+ }
}
if path != "/" {
path += "/"
}
for i := range list {
- walk(c, r, path+list[i].Name, &list[i], v, errors)
+ err = walk(c, r, path+list[i].Name, &list[i], v)
+ if err != nil {
+ break
+ }
}
+
+ return
}
Something went wrong with that request. Please try again.