mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-24 07:06:41 +00:00
Conflicting writes.
This commit is contained in:
parent
8c739343f3
commit
faacde4e32
@ -31,7 +31,7 @@ from cbor2 import dumps, loads
|
||||
from .server import StorageServer
|
||||
from .http_common import swissnum_auth_header, Secrets
|
||||
from .common import si_a2b
|
||||
from .immutable import BucketWriter
|
||||
from .immutable import BucketWriter, ConflictingWriteError
|
||||
from ..util.hashutil import timing_safe_compare
|
||||
from ..util.base32 import rfc3548_alphabet
|
||||
|
||||
@ -253,9 +253,11 @@ class HTTPServer(object):
|
||||
request.setResponseCode(http.NOT_FOUND)
|
||||
return b""
|
||||
|
||||
try:
|
||||
finished = bucket.write(offset, data)
|
||||
|
||||
# TODO if raises ConflictingWriteError, return HTTP CONFLICT code.
|
||||
except ConflictingWriteError:
|
||||
request.setResponseCode(http.CONFLICT)
|
||||
return b""
|
||||
|
||||
if finished:
|
||||
bucket.close()
|
||||
|
@ -626,9 +626,32 @@ class ImmutableHTTPAPITests(SyncTestCase):
|
||||
"""
|
||||
If an uploaded chunk conflicts with an already uploaded chunk, a
|
||||
CONFLICT error is returned.
|
||||
|
||||
TBD in https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3860
|
||||
"""
|
||||
(upload_secret, _, storage_index, created) = self.create_upload({1}, 100)
|
||||
|
||||
# Write:
|
||||
result_of(
|
||||
self.im_client.write_share_chunk(
|
||||
storage_index,
|
||||
1,
|
||||
upload_secret,
|
||||
0,
|
||||
b"0" * 10,
|
||||
)
|
||||
)
|
||||
|
||||
# Conflicting write:
|
||||
with self.assertRaises(ClientException) as e:
|
||||
result_of(
|
||||
self.im_client.write_share_chunk(
|
||||
storage_index,
|
||||
1,
|
||||
upload_secret,
|
||||
0,
|
||||
b"0123456789",
|
||||
)
|
||||
)
|
||||
self.assertEqual(e.exception.code, http.NOT_FOUND)
|
||||
|
||||
def test_read_of_wrong_storage_index_fails(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user