Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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
Show 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 (
...
@@ -37,7 +37,7 @@ import (
"lab.nexedi.com/kirr/go123/mem"
"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
{
func
pyQuote
(
s
string
)
string
{
out
:=
pyQuoteBytes
(
mem
.
Bytes
(
s
))
out
:=
pyQuoteBytes
(
mem
.
Bytes
(
s
))
return
mem
.
String
(
out
)
return
mem
.
String
(
out
)
...
@@ -82,7 +82,7 @@ func pyQuoteBytes(b []byte) []byte {
...
@@ -82,7 +82,7 @@ func pyQuoteBytes(b []byte) []byte {
buf
=
append
(
buf
,
[]
byte
(
fmt
.
Sprintf
(
"
\\
x%02x"
,
s
[
i
]))
...
)
buf
=
append
(
buf
,
[]
byte
(
fmt
.
Sprintf
(
"
\\
x%02x"
,
s
[
i
]))
...
)
default
:
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
// should be safe to reuse strconv.QuoteRune
rq
:=
strconv
.
QuoteRune
(
r
)
// "'\x01'"
rq
:=
strconv
.
QuoteRune
(
r
)
// "'\x01'"
rq
=
rq
[
1
:
len
(
rq
)
-
1
]
// "\x01"
rq
=
rq
[
1
:
len
(
rq
)
-
1
]
// "\x01"
...
@@ -95,15 +95,16 @@ func pyQuoteBytes(b []byte) []byte {
...
@@ -95,15 +95,16 @@ func pyQuoteBytes(b []byte) []byte {
return
buf
return
buf
}
}
func
fs
Dump
(
w
io
.
Writer
,
path
string
,
ntxn
int
)
(
err
error
)
{
func
fs
Tail
(
w
io
.
Writer
,
path
string
,
ntxn
int
)
(
err
error
)
{
// path & fs
dump
on error context
// path & fs
tail
on error context
defer
func
()
{
defer
func
()
{
if
err
!=
nil
{
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)
// (same logic as in fstail/py)
f
,
err
:=
os
.
Open
(
path
)
f
,
err
:=
os
.
Open
(
path
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -144,7 +145,7 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
...
@@ -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
)
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
--
{
for
i
:=
ntxn
;
i
>
0
;
i
--
{
err
=
txnh
.
LoadPrev
(
f
,
fs1
.
LoadAll
)
err
=
txnh
.
LoadPrev
(
f
,
fs1
.
LoadAll
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -180,6 +181,7 @@ func fsDump(w io.Writer, path string, ntxn int) (err error) {
...
@@ -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
// NOTE in zodb/py .length is len - 8, in zodb/go - whole txn record length
txnh
.
Len
-
8
,
txnh
.
Len
-
8
,
txnh
.
Pos
,
txnh
.
HeaderLen
())
txnh
.
Pos
,
txnh
.
HeaderLen
())
if
err
!=
nil
{
if
err
!=
nil
{
break
break
...
@@ -213,11 +215,11 @@ Dump transactions from a FileStorage in reverse order
...
@@ -213,11 +215,11 @@ Dump transactions from a FileStorage in reverse order
argv
:=
flag
.
Args
()
argv
:=
flag
.
Args
()
if
len
(
argv
)
<
1
{
if
len
(
argv
)
<
1
{
flag
.
Usage
()
flag
.
Usage
()
os
.
Exit
(
2
)
// XXX recheck it is same as from flag.Parse on -zzz
os
.
Exit
(
2
)
}
}
storPath
:=
argv
[
0
]
storPath
:=
argv
[
0
]
err
:=
fs
Dump
(
os
.
Stdout
,
storPath
,
ntxn
)
err
:=
fs
Tail
(
os
.
Stdout
,
storPath
,
ntxn
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
...
...
t/neo/zodb/cmd/zodbdump/zodbdump.go
View file @
98780ea4
...
@@ -209,7 +209,7 @@ func main() {
...
@@ -209,7 +209,7 @@ func main() {
argv
:=
flag
.
Args
()
argv
:=
flag
.
Args
()
if
len
(
argv
)
<
1
{
if
len
(
argv
)
<
1
{
usage
()
usage
()
os
.
Exit
(
2
)
// XXX recheck it is same as from flag.Parse on -zzz
os
.
Exit
(
2
)
}
}
storUrl
:=
argv
[
0
]
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