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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
ZODB
Commits
b15f9568
Commit
b15f9568
authored
Jun 10, 2007
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed files are read-only.
parent
1f74a566
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
3 deletions
+18
-3
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+2
-0
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+3
-0
src/ZODB/blob.py
src/ZODB/blob.py
+8
-3
src/ZODB/tests/blob_transaction.txt
src/ZODB/tests/blob_transaction.txt
+5
-0
No files found.
src/ZEO/ClientStorage.py
View file @
b15f9568
...
@@ -21,6 +21,7 @@ ClientStorage -- the main class, implementing the Storage API
...
@@ -21,6 +21,7 @@ ClientStorage -- the main class, implementing the Storage API
import
cPickle
import
cPickle
import
os
import
os
import
socket
import
socket
import
stat
import
sys
import
sys
import
tempfile
import
tempfile
import
threading
import
threading
...
@@ -952,6 +953,7 @@ class ClientStorage(object):
...
@@ -952,6 +953,7 @@ class ClientStorage(object):
def
receiveBlobStop
(
self
,
oid
,
serial
):
def
receiveBlobStop
(
self
,
oid
,
serial
):
blob_filename
=
self
.
fshelper
.
getBlobFilename
(
oid
,
serial
)
blob_filename
=
self
.
fshelper
.
getBlobFilename
(
oid
,
serial
)
os
.
rename
(
blob_filename
+
'.dl'
,
blob_filename
)
os
.
rename
(
blob_filename
+
'.dl'
,
blob_filename
)
os
.
chmod
(
blob_filename
,
stat
.
S_IREAD
)
def
loadBlob
(
self
,
oid
,
serial
):
def
loadBlob
(
self
,
oid
,
serial
):
...
...
src/ZEO/tests/testZEO.py
View file @
b15f9568
...
@@ -21,6 +21,7 @@ import os
...
@@ -21,6 +21,7 @@ import os
import
random
import
random
import
signal
import
signal
import
socket
import
socket
import
stat
import
tempfile
import
tempfile
import
threading
import
threading
import
time
import
time
...
@@ -532,6 +533,8 @@ class CommonBlobTests:
...
@@ -532,6 +533,8 @@ class CommonBlobTests:
filename
=
self
.
_storage
.
loadBlob
(
oid
,
serial
)
filename
=
self
.
_storage
.
loadBlob
(
oid
,
serial
)
self
.
assertEquals
(
somedata
,
open
(
filename
,
'rb'
).
read
())
self
.
assertEquals
(
somedata
,
open
(
filename
,
'rb'
).
read
())
self
.
assert_
(
not
(
os
.
stat
(
filename
).
st_mode
&
stat
.
S_IWRITE
))
self
.
assert_
((
os
.
stat
(
filename
).
st_mode
&
stat
.
S_IREAD
))
def
checkTemporaryDirectory
(
self
):
def
checkTemporaryDirectory
(
self
):
self
.
assertEquals
(
self
.
blob_cache_dir
,
self
.
assertEquals
(
self
.
blob_cache_dir
,
...
...
src/ZODB/blob.py
View file @
b15f9568
...
@@ -18,6 +18,7 @@ import base64
...
@@ -18,6 +18,7 @@ import base64
import
logging
import
logging
import
os
import
os
import
shutil
import
shutil
import
stat
import
sys
import
sys
import
tempfile
import
tempfile
import
threading
import
threading
...
@@ -191,7 +192,7 @@ class Blob(persistent.Persistent):
...
@@ -191,7 +192,7 @@ class Blob(persistent.Persistent):
os
.
unlink
(
target
)
os
.
unlink
(
target
)
try
:
try
:
rename_or_copy_blob
(
filename
,
target
)
rename_or_copy_blob
(
filename
,
target
,
chmod
=
False
)
except
:
except
:
# Recover from the failed consumption: First remove the file, it
# Recover from the failed consumption: First remove the file, it
# might exist and mark the pointer to the uncommitted file.
# might exist and mark the pointer to the uncommitted file.
...
@@ -579,12 +580,14 @@ class BlobStorage(SpecificationDecoratorBase):
...
@@ -579,12 +580,14 @@ class BlobStorage(SpecificationDecoratorBase):
load_result
=
self
.
loadBefore
(
oid
,
serial_id
)
load_result
=
self
.
loadBefore
(
oid
,
serial_id
)
if
load_result
is
None
:
if
load_result
is
None
:
# There was no previous revision of this blob
# There was no previous revision of this blob
# object. The blob was created in the transaction
# object. The blob was created in the transaction
# represented by serial_id. We copy the blob data
# represented by serial_id. We copy the blob data
# to a new file that references the undo
# to a new file that references the undo
# transaction in case a user wishes to undo this
# transaction in case a user wishes to undo this
# undo.
# undo. It would be nice if we had some way to
# link to old blobs.
orig_fn
=
self
.
fshelper
.
getBlobFilename
(
oid
,
serial_id
)
orig_fn
=
self
.
fshelper
.
getBlobFilename
(
oid
,
serial_id
)
new_fn
=
self
.
fshelper
.
getBlobFilename
(
oid
,
undo_serial
)
new_fn
=
self
.
fshelper
.
getBlobFilename
(
oid
,
undo_serial
)
else
:
else
:
...
@@ -608,7 +611,7 @@ class BlobStorage(SpecificationDecoratorBase):
...
@@ -608,7 +611,7 @@ class BlobStorage(SpecificationDecoratorBase):
copied
=
logging
.
getLogger
(
'ZODB.blob.copied'
).
debug
copied
=
logging
.
getLogger
(
'ZODB.blob.copied'
).
debug
def
rename_or_copy_blob
(
f1
,
f2
):
def
rename_or_copy_blob
(
f1
,
f2
,
chmod
=
True
):
"""Try to rename f1 to f2, fallback to copy.
"""Try to rename f1 to f2, fallback to copy.
Under certain conditions a rename might not work, e.g. because the target
Under certain conditions a rename might not work, e.g. because the target
...
@@ -622,3 +625,5 @@ def rename_or_copy_blob(f1, f2):
...
@@ -622,3 +625,5 @@ def rename_or_copy_blob(f1, f2):
copied
(
"Copied blob file %r to %r."
,
f1
,
f2
)
copied
(
"Copied blob file %r to %r."
,
f1
,
f2
)
utils
.
cp
(
open
(
f1
,
'rb'
),
open
(
f2
,
'wb'
))
utils
.
cp
(
open
(
f1
,
'rb'
),
open
(
f2
,
'wb'
))
os
.
unlink
(
f1
)
os
.
unlink
(
f1
)
if
chmod
:
os
.
chmod
(
f2
,
stat
.
S_IREAD
)
src/ZODB/tests/blob_transaction.txt
View file @
b15f9568
...
@@ -303,7 +303,12 @@ uncommitted changes:
...
@@ -303,7 +303,12 @@ uncommitted changes:
>>> open(blob.committed()).read()
>>> open(blob.committed()).read()
"I'm a happy blob."
"I'm a happy blob."
You can't open a committed blob file for writing:
>>> open(blob.committed(), 'w') # doctest: +ELLIPSIS
Traceback (most recent call last):
...
IOError: ...
Teardown
Teardown
...
...
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