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
5097617b
Commit
5097617b
authored
Jun 10, 2007
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed files are read-only.
parent
4cce220f
Changes
4
Hide 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 @
5097617b
...
...
@@ -21,6 +21,7 @@ ClientStorage -- the main class, implementing the Storage API
import
cPickle
import
os
import
socket
import
stat
import
sys
import
tempfile
import
threading
...
...
@@ -952,6 +953,7 @@ class ClientStorage(object):
def
receiveBlobStop
(
self
,
oid
,
serial
):
blob_filename
=
self
.
fshelper
.
getBlobFilename
(
oid
,
serial
)
os
.
rename
(
blob_filename
+
'.dl'
,
blob_filename
)
os
.
chmod
(
blob_filename
,
stat
.
S_IREAD
)
def
loadBlob
(
self
,
oid
,
serial
):
...
...
src/ZEO/tests/testZEO.py
View file @
5097617b
...
...
@@ -21,6 +21,7 @@ import os
import
random
import
signal
import
socket
import
stat
import
tempfile
import
threading
import
time
...
...
@@ -532,6 +533,8 @@ class CommonBlobTests:
filename
=
self
.
_storage
.
loadBlob
(
oid
,
serial
)
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
):
self
.
assertEquals
(
self
.
blob_cache_dir
,
...
...
src/ZODB/blob.py
View file @
5097617b
...
...
@@ -18,6 +18,7 @@ import base64
import
logging
import
os
import
shutil
import
stat
import
sys
import
tempfile
import
threading
...
...
@@ -191,7 +192,7 @@ class Blob(persistent.Persistent):
os
.
unlink
(
target
)
try
:
rename_or_copy_blob
(
filename
,
target
)
rename_or_copy_blob
(
filename
,
target
,
chmod
=
False
)
except
:
# Recover from the failed consumption: First remove the file, it
# might exist and mark the pointer to the uncommitted file.
...
...
@@ -579,12 +580,14 @@ class BlobStorage(SpecificationDecoratorBase):
load_result
=
self
.
loadBefore
(
oid
,
serial_id
)
if
load_result
is
None
:
# There was no previous revision of this blob
# object. The blob was created in the transaction
# represented by serial_id. We copy the blob data
# to a new file that references the undo
# 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
)
new_fn
=
self
.
fshelper
.
getBlobFilename
(
oid
,
undo_serial
)
else
:
...
...
@@ -608,7 +611,7 @@ class BlobStorage(SpecificationDecoratorBase):
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.
Under certain conditions a rename might not work, e.g. because the target
...
...
@@ -622,3 +625,5 @@ def rename_or_copy_blob(f1, f2):
copied
(
"Copied blob file %r to %r."
,
f1
,
f2
)
utils
.
cp
(
open
(
f1
,
'rb'
),
open
(
f2
,
'wb'
))
os
.
unlink
(
f1
)
if
chmod
:
os
.
chmod
(
f2
,
stat
.
S_IREAD
)
src/ZODB/tests/blob_transaction.txt
View file @
5097617b
...
...
@@ -303,7 +303,12 @@ uncommitted changes:
>>> open(blob.committed()).read()
"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
...
...
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