Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
98780ea4
Commit
98780ea4
authored
Mar 15, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1eb56978
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
t/neo/storage/fs1/cmd/fstail/fstail.go
t/neo/storage/fs1/cmd/fstail/fstail.go
+11
-9
t/neo/zodb/cmd/zodbdump/zodbdump.go
t/neo/zodb/cmd/zodbdump/zodbdump.go
+1
-1
No files found.
t/neo/storage/fs1/cmd/fstail/fstail.go
View file @
98780ea4
...
...
@@ -37,7 +37,7 @@ import (
"lab.nexedi.com/kirr/go123/mem"
)
// pyQuote quotes string the way python repr(str) would do
it
// pyQuote quotes string the way python repr(str) would do
func
pyQuote
(
s
string
)
string
{
out
:=
pyQuoteBytes
(
mem
.
Bytes
(
s
))
return
mem
.
String
(
out
)
...
...
@@ -82,7 +82,7 @@ func pyQuoteBytes(b []byte) []byte {
buf
=
append
(
buf
,
[]
byte
(
fmt
.
Sprintf
(
"
\\
x%02x"
,
s
[
i
]))
...
)
default
:
// we aleady handled ', " and (< ' ') above, so now it
// we al
r
eady handled ', " and (< ' ') above, so now it
// should be safe to reuse strconv.QuoteRune
rq
:=
strconv
.
QuoteRune
(
r
)
// "'\x01'"
rq
=
rq
[
1
:
len
(
rq
)
-
1
]
// "\x01"
...
...
@@ -95,15 +95,16 @@ func pyQuoteBytes(b []byte) []byte {
return
buf
}
func
fs
Dump
(
w
io
.
Writer
,
path
string
,
ntxn
int
)
(
err
error
)
{
// path & fs
dump
on error context
func
fs
Tail
(
w
io
.
Writer
,
path
string
,
ntxn
int
)
(
err
error
)
{
// path & fs
tail
on error context
defer
func
()
{
if
err
!=
nil
{
err
=
fmt
.
Errorf
(
"%s: fs
dump
: %v"
,
path
,
err
)
err
=
fmt
.
Errorf
(
"%s: fs
tail
: %v"
,
path
,
err
)
}
}()
// we are not using fs1.Open here, since the file could be e.g. corrupt
// we are not using fs1.Open here, since the file or index could be
// e.g. corrupt - we want to iterate directly by FileStorage records
// (same logic as in fstail/py)
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
...
...
@@ -144,7 +145,7 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
return
fmt
.
Errorf
(
"@%v: previous record could not be read"
,
topPos
)
}
// now loop loading
previous txn
until EOF / ntxn limit
// now loop loading
transactions backwards
until EOF / ntxn limit
for
i
:=
ntxn
;
i
>
0
;
i
--
{
err
=
txnh
.
LoadPrev
(
f
,
fs1
.
LoadAll
)
if
err
!=
nil
{
...
...
@@ -180,6 +181,7 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
txnh
.
Len
-
8
,
txnh
.
Pos
,
txnh
.
HeaderLen
())
if
err
!=
nil
{
break
...
...
@@ -213,11 +215,11 @@ Dump transactions from a FileStorage in reverse order
argv
:=
flag
.
Args
()
if
len
(
argv
)
<
1
{
flag
.
Usage
()
os
.
Exit
(
2
)
// XXX recheck it is same as from flag.Parse on -zzz
os
.
Exit
(
2
)
}
storPath
:=
argv
[
0
]
err
:=
fs
Dump
(
os
.
Stdout
,
storPath
,
ntxn
)
err
:=
fs
Tail
(
os
.
Stdout
,
storPath
,
ntxn
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
t/neo/zodb/cmd/zodbdump/zodbdump.go
View file @
98780ea4
...
...
@@ -209,7 +209,7 @@ func main() {
argv
:=
flag
.
Args
()
if
len
(
argv
)
<
1
{
usage
()
os
.
Exit
(
2
)
// XXX recheck it is same as from flag.Parse on -zzz
os
.
Exit
(
2
)
}
storUrl
:=
argv
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment