Commit 35a0803c authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent db60a77f
...@@ -38,6 +38,7 @@ import ( ...@@ -38,6 +38,7 @@ import (
"os" "os"
"../../../zodb" "../../../zodb"
"../../../storage/fs1"
"lab.nexedi.com/kirr/go123/mem" "lab.nexedi.com/kirr/go123/mem"
"lab.nexedi.com/kirr/go123/xio" "lab.nexedi.com/kirr/go123/xio"
...@@ -109,7 +110,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly ...@@ -109,7 +110,7 @@ func zodbDump(w io.Writer, stor zodb.IStorage, tidMin, tidMax zodb.Tid, hashOnly
func usage() { func usage() {
fmt.Fprintf(os.Stderr, fmt.Fprintf(os.Stderr,
`zodbdump [options] <command> [tidmin..tidmax] `zodbdump [options] <storage> [tidmin..tidmax]
Dump content of a ZODB database. Dump content of a ZODB database.
<storage> is a path to FileStorage XXX will become URL <storage> is a path to FileStorage XXX will become URL
...@@ -123,8 +124,7 @@ Dump content of a ZODB database. ...@@ -123,8 +124,7 @@ Dump content of a ZODB database.
func main() { func main() {
hashOnly := false hashOnly := false
tidMin := zodb.Tid(0) tidRange := ".." // (0, +inf)
tidMax := zodb.TidMax
flag.Usage = usage flag.Usage = usage
flag.BoolVar(&hashOnly, "hashonly", hashOnly, "dump only hashes of objects") flag.BoolVar(&hashOnly, "hashonly", hashOnly, "dump only hashes of objects")
...@@ -137,14 +137,19 @@ func main() { ...@@ -137,14 +137,19 @@ func main() {
} }
storUrl := argv[0] storUrl := argv[0]
var err error
if len(argv) > 1 { if len(argv) > 1 {
tidMin, tidMax, err = parseTidRange(argv[1]) tidRange = argv[1]
if err != nil { }
log.Fatal(err) // XXX recheck
} tidMin, tidMax, err := zodb.ParseTidRange(tidRange)
if err != nil {
log.Fatal(err) // XXX recheck
} }
stor, err = fs1.Open(storUrl) // TODO read-only stor, err := fs1.Open(storUrl) // TODO read-only
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
......
...@@ -69,6 +69,7 @@ func ParseOid(s string) (Oid, error) { ...@@ -69,6 +69,7 @@ func ParseOid(s string) (Oid, error) {
// ParseTidRange parses string of form "<tidmin>..<tidmax>" into tidMin, tidMax pair // ParseTidRange parses string of form "<tidmin>..<tidmax>" into tidMin, tidMax pair
// both <tidmin> and <tidmax> can be empty, in which case defaults 0 and TidMax are returned // both <tidmin> and <tidmax> can be empty, in which case defaults 0 and TidMax are returned
// XXX also check tidMin < tidMax here? or allow reverse ranges ?
func ParseTidRange(s string) (tidMin, tidMax Tid, err error) { func ParseTidRange(s string) (tidMin, tidMax Tid, err error) {
s1, s2, err := xstrings.Split2(s, "..") s1, s2, err := xstrings.Split2(s, "..")
if err != nil { if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment