Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kirill Smelkov
ZEO
Commits
bc3d1097
Commit
bc3d1097
authored
22 years ago
by
Jeremy Hylton
Browse files
Options
Download
Email Patches
Plain Diff
Provide much simpler version of getSerial().
parent
32f4f31c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
28 deletions
+9
-28
src/ZODB/FileStorage.py
src/ZODB/FileStorage.py
+9
-28
No files found.
src/ZODB/FileStorage.py
View file @
bc3d1097
...
...
@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version
# record.
#
__version__
=
'$Revision: 1.11
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.11
7
$'
[
11
:
-
2
]
import
base64
from
cPickle
import
Pickler
,
Unpickler
,
loads
...
...
@@ -573,31 +573,6 @@ class FileStorage(BaseStorage.BaseStorage,
if
plen
!=
z64
:
return
read
(
U64
(
plen
)),
version
,
nv
return
_loadBack
(
file
,
oid
,
read
(
8
))[
0
],
version
,
nv
def
getSerial
(
self
,
oid
):
self
.
_lock_acquire
()
try
:
pos
=
self
.
_index
[
oid
]
self
.
_file
.
seek
(
pos
)
h
=
self
.
_file
.
read
(
34
)
_oid
=
h
[:
8
]
if
_oid
!=
oid
:
raise
CorruptedDataError
,
h
vlen
=
unpack
(
">H"
,
h
[
-
2
:])[
0
]
if
vlen
:
# If there is a version, find out its name and let
# _load() do all the work. This is less efficient
# than possible, because _load() will load the pickle
# data. Being more efficient is too complicated.
self
.
_file
.
seek
(
24
,
1
)
# skip plen, pnv, and pv
version
=
self
.
_file
.
read
(
vlen
)
pickledata
,
serial
=
self
.
_load
(
oid
,
version
,
self
.
_index
,
self
.
_file
)
return
serial
return
h
[
8
:
16
]
finally
:
self
.
_lock_release
()
def
_load
(
self
,
oid
,
version
,
_index
,
file
):
try
:
pos
=
_index
[
oid
]
...
...
@@ -1045,6 +1020,13 @@ class FileStorage(BaseStorage.BaseStorage,
else
:
return
''
,
''
def
getSerial
(
self
,
oid
):
self
.
_lock_acquire
()
try
:
return
self
.
_getSerial
(
oid
,
self
.
_index
[
oid
])
finally
:
self
.
_lock_release
()
def
_getSerial
(
self
,
oid
,
pos
):
self
.
_file
.
seek
(
pos
)
h
=
self
.
_file
.
read
(
16
)
...
...
@@ -1222,8 +1204,7 @@ class FileStorage(BaseStorage.BaseStorage,
while
pos
<
tend
:
self
.
_file
.
seek
(
pos
)
h
=
self
.
_file
.
read
(
DATA_HDR_LEN
)
oid
,
serial
,
sprev
,
stloc
,
vlen
,
splen
=
\
struct
.
unpack
(
DATA_HDR
,
h
)
oid
,
serial
,
sprev
,
stloc
,
vlen
,
splen
=
struct
.
unpack
(
DATA_HDR
,
h
)
if
failed
(
oid
):
del
failures
[
oid
]
# second chance!
plen
=
U64
(
splen
)
...
...
This diff is collapsed.
Click to expand it.
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