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
4fa93367
Commit
4fa93367
authored
Apr 02, 2017
by
Jim Fulton
Committed by
GitHub
Apr 02, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #153 from navytux/y/fs-ro
FileStorage: Report problem on read-only open of non-existent file
parents
3a8efe47
30bbabf1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
src/ZODB/FileStorage/FileStorage.py
src/ZODB/FileStorage/FileStorage.py
+4
-0
src/ZODB/tests/testConfig.py
src/ZODB/tests/testConfig.py
+10
-0
src/ZODB/tests/testFileStorage.py
src/ZODB/tests/testFileStorage.py
+13
-0
No files found.
src/ZODB/FileStorage/FileStorage.py
View file @
4fa93367
...
@@ -267,6 +267,10 @@ class FileStorage(
...
@@ -267,6 +267,10 @@ class FileStorage(
if
exc
.
errno
==
errno
.
EFBIG
:
if
exc
.
errno
==
errno
.
EFBIG
:
# The file is too big to open. Fail visibly.
# The file is too big to open. Fail visibly.
raise
raise
if
read_only
:
# When open request is read-only we do not want to create
# the file
raise
if
exc
.
errno
==
errno
.
ENOENT
:
if
exc
.
errno
==
errno
.
ENOENT
:
# The file doesn't exist. Create it.
# The file doesn't exist. Create it.
create
=
1
create
=
1
...
...
src/ZODB/tests/testConfig.py
View file @
4fa93367
...
@@ -73,6 +73,16 @@ class ZODBConfigTest(ConfigTestBase):
...
@@ -73,6 +73,16 @@ class ZODBConfigTest(ConfigTestBase):
def
test_file_config2
(
self
):
def
test_file_config2
(
self
):
path
=
tempfile
.
mktemp
()
path
=
tempfile
.
mktemp
()
# first pass to actually create database file
self
.
_test
(
"""
<zodb>
<filestorage>
path %s
</filestorage>
</zodb>
"""
%
path
)
# write operations must be disallowed on read-only access
cfg
=
"""
cfg
=
"""
<zodb>
<zodb>
<filestorage>
<filestorage>
...
...
src/ZODB/tests/testFileStorage.py
View file @
4fa93367
...
@@ -689,6 +689,19 @@ def pack_with_open_blob_files():
...
@@ -689,6 +689,19 @@ def pack_with_open_blob_files():
>>> db.close()
>>> db.close()
"""
"""
def
readonly_open_nonexistent_file
():
"""
Make sure error is reported when non-existent file is tried to be opened
read-only.
>>> try:
... fs = ZODB.FileStorage.FileStorage('nonexistent.fs', read_only=True)
... except Exception as e:
... # Python2 raises IOError; Python3 - FileNotFoundError
... print("error: %s" % str(e)) # doctest: +ELLIPSIS
error: ... No such file or directory: 'nonexistent.fs'
"""
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
for
klass
in
[
for
klass
in
[
...
...
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