Commit 68609005 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 2f69e47b
// Copyright (C) 2017-2019 Nexedi SA and Contributors. // Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -125,25 +125,37 @@ func catobjMain(argv []string) { ...@@ -125,25 +125,37 @@ func catobjMain(argv []string) {
} }
ctx := context.Background() ctx := context.Background()
err := func() (err error) {
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true}) stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil { if err != nil {
prog.Fatal(err) return err
} }
// TODO defer stor.Close() defer func() {
err2 := stor.Close()
catobj := func(xid zodb.Xid) error { if err == nil {
if raw { err = err2
return Catobj(ctx, os.Stdout, stor, xid) }
} else { }()
return Dumpobj(ctx, os.Stdout, stor, xid, hashOnly)
catobj := func(xid zodb.Xid) error {
if raw {
return Catobj(ctx, os.Stdout, stor, xid)
} else {
return Dumpobj(ctx, os.Stdout, stor, xid, hashOnly)
}
} }
}
for _, xid := range xidv { for _, xid := range xidv {
err = catobj(xid) err = catobj(xid)
if err != nil { if err != nil {
prog.Fatal(err) return err
}
} }
return nil
}()
if err != nil {
prog.Fatal(err)
} }
} }
...@@ -256,20 +256,27 @@ func dumpMain(argv []string) { ...@@ -256,20 +256,27 @@ func dumpMain(argv []string) {
tidRange = argv[1] tidRange = argv[1]
} }
tidMin, tidMax, err := zodb.ParseTidRange(tidRange)
if err != nil {
prog.Fatal(err)
}
ctx := context.Background() ctx := context.Background()
err := func() (err error) {
tidMin, tidMax, err := zodb.ParseTidRange(tidRange)
if err != nil {
return err
}
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true}) stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil { if err != nil {
prog.Fatal(err) return err
} }
// TODO defer stor.Close() defer func() {
err2 := stor.Close()
if err == nil {
err = err2
}
}()
return Dump(ctx, os.Stdout, stor, tidMin, tidMax, hashOnly)
}()
err = Dump(ctx, os.Stdout, stor, tidMin, tidMax, hashOnly)
if err != nil { if err != nil {
prog.Fatal(err) prog.Fatal(err)
} }
......
// Copyright (C) 2017-2019 Nexedi SA and Contributors. // Copyright (C) 2017-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -127,14 +127,21 @@ func infoMain(argv []string) { ...@@ -127,14 +127,21 @@ func infoMain(argv []string) {
zurl := argv[0] zurl := argv[0]
ctx := context.Background() ctx := context.Background()
err := func() (err error) {
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
return err
}
defer func() {
err2 := stor.Close()
if err == nil {
err = err2
}
}()
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true}) return Info(ctx, os.Stdout, stor, argv[1:])
if err != nil { }()
prog.Fatal(err)
}
// TODO defer stor.Close()
err = Info(ctx, os.Stdout, stor, argv[1:])
if err != nil { if err != nil {
prog.Fatal(err) prog.Fatal(err)
} }
......
...@@ -152,23 +152,23 @@ func watchMain(argv []string) { ...@@ -152,23 +152,23 @@ func watchMain(argv []string) {
} }
zurl := argv[0] zurl := argv[0]
err := watchMain_(context.Background(), zurl, verbose) ctx := context.Background()
if err != nil { err := func() (err error) {
prog.Fatal(err) stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
} if err != nil {
} return err
func watchMain_(ctx context.Context, zurl string, verbose bool) (err error) {
stor, err := zodb.Open(ctx, zurl, &zodb.OpenOptions{ReadOnly: true})
if err != nil {
return err
}
defer func() {
err2 := stor.Close()
if err == nil {
err = err2
} }
defer func() {
err2 := stor.Close()
if err == nil {
err = err2
}
}()
return Watch(ctx, stor, os.Stdout, verbose)
}() }()
return Watch(ctx, stor, os.Stdout, verbose) if err != nil {
prog.Fatal(err)
}
} }
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