Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Kirill Smelkov
ZODB
Commits
e8c35106
Commit
e8c35106
authored
Oct 16, 2002
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge the rest of the restore() fix from release branch.
parent
4d37947b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
32 deletions
+23
-32
src/ZODB/FileStorage.py
src/ZODB/FileStorage.py
+23
-32
No files found.
src/ZODB/FileStorage.py
View file @
e8c35106
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version
# may have a back pointer to a version record or to a non-version
# record.
# record.
#
#
__version__
=
'$Revision: 1.10
6
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.10
7
$'
[
11
:
-
2
]
import
base64
import
base64
from
cPickle
import
Pickler
,
Unpickler
,
loads
from
cPickle
import
Pickler
,
Unpickler
,
loads
...
@@ -684,16 +684,14 @@ class FileStorage(BaseStorage.BaseStorage,
...
@@ -684,16 +684,14 @@ class FileStorage(BaseStorage.BaseStorage,
old
=
self
.
_index_get
(
oid
,
0
)
old
=
self
.
_index_get
(
oid
,
0
)
pnv
=
None
pnv
=
None
if
old
:
if
old
:
file
=
self
.
_file
self
.
_file
.
seek
(
old
)
file
.
seek
(
old
)
h
=
self
.
_file
.
read
(
DATA_HDR_LEN
)
read
=
file
.
read
h
=
read
(
DATA_HDR_LEN
)
doid
,
oserial
,
sprev
,
stloc
,
vlen
,
splen
=
unpack
(
">8s8s8s8sH8s"
,
h
)
doid
,
oserial
,
sprev
,
stloc
,
vlen
,
splen
=
unpack
(
">8s8s8s8sH8s"
,
h
)
if
doid
!=
oid
:
raise
CorruptedDataError
,
h
if
doid
!=
oid
:
raise
CorruptedDataError
,
h
if
vlen
:
if
vlen
:
pnv
=
read
(
8
)
# non-version data pointer
pnv
=
self
.
_file
.
read
(
8
)
# non-version data pointer
read
(
8
)
# skip past version link
self
.
_file
.
read
(
8
)
# skip past version link
locked_version
=
read
(
vlen
)
locked_version
=
self
.
_file
.
read
(
vlen
)
if
version
!=
locked_version
:
if
version
!=
locked_version
:
raise
POSException
.
VersionLockError
,
(
raise
POSException
.
VersionLockError
,
(
`oid`
,
locked_version
)
`oid`
,
locked_version
)
...
@@ -762,25 +760,7 @@ class FileStorage(BaseStorage.BaseStorage,
...
@@ -762,25 +760,7 @@ class FileStorage(BaseStorage.BaseStorage,
self
.
_lock_acquire
()
self
.
_lock_acquire
()
try
:
try
:
# Position of the non-version data
pnv
=
None
# We need to get some information about previous revisions
# of the object. Specifically, we need the position of
# the non-version data if this update is in a version. We
# also need the position of the previous record in this
# version.
old
=
self
.
_index_get
(
oid
,
0
)
old
=
self
.
_index_get
(
oid
,
0
)
if
old
:
self
.
_file
.
seek
(
old
)
# Read the previous revision record
h
=
self
.
_file
.
read
(
42
)
doid
,
oserial
,
sprev
,
stloc
,
vlen
,
splen
=
unpack
(
">8s8s8s8sH8s"
,
h
)
if
doid
!=
oid
:
raise
CorruptedDataError
,
h
if
vlen
>
0
:
# non-version data pointer
pnv
=
self
.
_file
.
read
(
8
)
# Calculate the file position in the temporary file
# Calculate the file position in the temporary file
here
=
self
.
_pos
+
self
.
_tfile
.
tell
()
+
self
.
_thl
here
=
self
.
_pos
+
self
.
_tfile
.
tell
()
+
self
.
_thl
# And update the temp file index
# And update the temp file index
...
@@ -796,9 +776,20 @@ class FileStorage(BaseStorage.BaseStorage,
...
@@ -796,9 +776,20 @@ class FileStorage(BaseStorage.BaseStorage,
# We need to write some version information if this revision is
# We need to write some version information if this revision is
# happening in a version.
# happening in a version.
if
version
:
if
version
:
# If there's a previous revision in this version, write the
pnv
=
None
# position, otherwise write the position of the previous
# We need to write the position of the non-version data.
# non-version revision.
# If the previous revision of the object was in a version,
# then it will contain a pnv record. Otherwise, the
# previous record is the non-version data.
if
old
:
self
.
_file
.
seek
(
old
)
h
=
self
.
_file
.
read
(
42
)
doid
,
x
,
y
,
z
,
vlen
,
w
=
unpack
(
">8s8s8s8sH8s"
,
h
)
if
doid
!=
oid
:
raise
CorruptedDataError
,
h
# XXX assert versions match?
if
vlen
>
0
:
pnv
=
self
.
_file
.
read
(
8
)
if
pnv
:
if
pnv
:
self
.
_tfile
.
write
(
pnv
)
self
.
_tfile
.
write
(
pnv
)
else
:
else
:
...
@@ -806,14 +797,14 @@ class FileStorage(BaseStorage.BaseStorage,
...
@@ -806,14 +797,14 @@ class FileStorage(BaseStorage.BaseStorage,
# Link to the last record for this version
# Link to the last record for this version
pv
=
self
.
_tvindex
.
get
(
version
,
0
)
pv
=
self
.
_tvindex
.
get
(
version
,
0
)
if
not
pv
:
if
not
pv
:
self
.
_vindex_get
(
version
,
0
)
pv
=
self
.
_vindex_get
(
version
,
0
)
self
.
_tfile
.
write
(
p64
(
pv
))
self
.
_tfile
.
write
(
p64
(
pv
))
self
.
_tvindex
[
version
]
=
here
self
.
_tvindex
[
version
]
=
here
self
.
_tfile
.
write
(
version
)
self
.
_tfile
.
write
(
version
)
# And finally, write the data
# And finally, write the data
if
data
is
None
:
if
data
is
None
:
# Write a zero backpointer, which i
s indication used to
# Write a zero backpointer, which i
ndicates an
#
represent an
un-creation transaction.
# un-creation transaction.
self
.
_tfile
.
write
(
z64
)
self
.
_tfile
.
write
(
z64
)
else
:
else
:
self
.
_tfile
.
write
(
data
)
self
.
_tfile
.
write
(
data
)
...
...
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