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:
import
getopt
,
ZODB
.
FileStorage
,
struct
,
time
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
cPickle
import
loads
from
ZODB.FileStorage
import
RecordIterator
...
...
@@ -150,25 +150,37 @@ def read_transaction_header(file, pos, file_size):
return
pos
,
result
def
scan
(
file
,
pos
,
file_size
):
seek
=
file
.
seek
read
=
file
.
read
def
scan
(
file
,
pos
):
"""Return a potential transaction location following pos in file.
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
:
seek
(
pos
)
data
=
read
(
8096
)
if
not
data
:
return
0
file
.
seek
(
pos
)
data
=
file
.
read
(
8096
)
if
not
data
:
return
0
s
=
0
s
=
0
while
1
:
l
=
data
.
find
(
'.'
,
s
)
l
=
data
.
find
(
'.'
,
s
)
if
l
<
0
:
pos
=
pos
+
8096
pos
+=
len
(
data
)
break
if
l
>
8080
:
pos
=
pos
+
l
# If we are less than 8 bytes from the end of the
# string, we need to read more data.
if
l
>
len
(
data
)
-
8
:
pos
+=
l
break
s
=
l
+
1
tl
=
U
64
(
data
[
s
:
s
+
8
])
s
=
l
+
1
tl
=
u
64
(
data
[
s
:
s
+
8
])
if
tl
<
pos
:
return
pos
+
s
+
8
...
...
@@ -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
]
if
not
verbose
:
progress
(
prog1
)
pos
=
scan
(
file
,
pos
,
file_size
)
pos
=
scan
(
file
,
pos
)
continue
if
transaction
is
None
:
...
...
@@ -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
]
if
not
verbose
:
progress
(
prog1
)
pos
=
scan
(
file
,
pos
,
file_size
)
pos
=
scan
(
file
,
pos
)
else
:
ofs
.
tpc_vote
(
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