Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
b34ab889
Commit
b34ab889
authored
May 01, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite scan for clarity. Add doc string and comment.
parent
6880d7c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
16 deletions
+28
-16
src/ZODB/fsrecover.py
src/ZODB/fsrecover.py
+28
-16
No files found.
src/ZODB/fsrecover.py
View file @
b34ab889
...
@@ -84,7 +84,7 @@ except ImportError:
...
@@ -84,7 +84,7 @@ except ImportError:
import
getopt
,
ZODB
.
FileStorage
,
struct
,
time
import
getopt
,
ZODB
.
FileStorage
,
struct
,
time
from
struct
import
unpack
from
struct
import
unpack
from
ZODB.utils
import
t32
,
p64
,
U
64
from
ZODB.utils
import
t32
,
p64
,
u
64
from
ZODB.TimeStamp
import
TimeStamp
from
ZODB.TimeStamp
import
TimeStamp
from
cPickle
import
loads
from
cPickle
import
loads
from
ZODB.FileStorage
import
RecordIterator
from
ZODB.FileStorage
import
RecordIterator
...
@@ -150,25 +150,37 @@ def read_transaction_header(file, pos, file_size):
...
@@ -150,25 +150,37 @@ def read_transaction_header(file, pos, file_size):
return
pos
,
result
return
pos
,
result
def
scan
(
file
,
pos
,
file_size
):
def
scan
(
file
,
pos
):
seek
=
file
.
seek
"""Return a potential transaction location following pos in file.
read
=
file
.
read
This routine scans forward from pos looking for the last data
record in a transaction. A period '.' always occurs at the end of
a pickle, and an 8-byte transaction length follows the last
pickle. If a period is followed by a plausible 8-byte transaction
length, assume that we have found the end of a transaction.
The caller should try to verify that the returned location is
actually a transaction header.
"""
while
1
:
while
1
:
seek
(
pos
)
file
.
seek
(
pos
)
data
=
read
(
8096
)
data
=
file
.
read
(
8096
)
if
not
data
:
return
0
if
not
data
:
return
0
s
=
0
s
=
0
while
1
:
while
1
:
l
=
data
.
find
(
'.'
,
s
)
l
=
data
.
find
(
'.'
,
s
)
if
l
<
0
:
if
l
<
0
:
pos
=
pos
+
8096
pos
+=
len
(
data
)
break
break
if
l
>
8080
:
# If we are less than 8 bytes from the end of the
pos
=
pos
+
l
# string, we need to read more data.
if
l
>
len
(
data
)
-
8
:
pos
+=
l
break
break
s
=
l
+
1
s
=
l
+
1
tl
=
U
64
(
data
[
s
:
s
+
8
])
tl
=
u
64
(
data
[
s
:
s
+
8
])
if
tl
<
pos
:
if
tl
<
pos
:
return
pos
+
s
+
8
return
pos
+
s
+
8
...
@@ -234,7 +246,7 @@ def recover(inp, outp, verbose=0, partial=0, force=0, pack=0):
...
@@ -234,7 +246,7 @@ def recover(inp, outp, verbose=0, partial=0, force=0, pack=0):
print
"
\
n
%s: %s
\
n
"
%
sys
.
exc_info
()[:
2
]
print
"
\
n
%s: %s
\
n
"
%
sys
.
exc_info
()[:
2
]
if
not
verbose
:
if
not
verbose
:
progress
(
prog1
)
progress
(
prog1
)
pos
=
scan
(
file
,
pos
,
file_size
)
pos
=
scan
(
file
,
pos
)
continue
continue
if
transaction
is
None
:
if
transaction
is
None
:
...
@@ -298,7 +310,7 @@ def recover(inp, outp, verbose=0, partial=0, force=0, pack=0):
...
@@ -298,7 +310,7 @@ def recover(inp, outp, verbose=0, partial=0, force=0, pack=0):
print
"
\
n
%s: %s
\
n
"
%
sys
.
exc_info
()[:
2
]
print
"
\
n
%s: %s
\
n
"
%
sys
.
exc_info
()[:
2
]
if
not
verbose
:
if
not
verbose
:
progress
(
prog1
)
progress
(
prog1
)
pos
=
scan
(
file
,
pos
,
file_size
)
pos
=
scan
(
file
,
pos
)
else
:
else
:
ofs
.
tpc_vote
(
transaction
)
ofs
.
tpc_vote
(
transaction
)
ofs
.
tpc_finish
(
transaction
)
ofs
.
tpc_finish
(
transaction
)
...
...
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