Treat missing Store documents as normal absence
Debian Trixie package bundle / packages (push) Successful in 22m0s
Debian Trixie package bundle / packages (push) Successful in 22m0s
This commit is contained in:
@@ -108,17 +108,13 @@ class DocumentPutCommand(Command):
|
||||
|
||||
try:
|
||||
store.Store(options.store)
|
||||
f = open(filename, "rb")
|
||||
content = f.read()
|
||||
try:
|
||||
store.Info(document)
|
||||
# Info throws an exception if the document doesn't exist
|
||||
with open(filename, "rb") as source:
|
||||
content = source.read()
|
||||
if store.Info(document) is not None:
|
||||
store.Replace(document, content)
|
||||
except:
|
||||
# doesn't exist, so must write the new document
|
||||
store.Write(doc_collection, doc_type, content, filename=doc_name)
|
||||
|
||||
f.close()
|
||||
else:
|
||||
store.Write(doc_collection, doc_type, content,
|
||||
filename=doc_name)
|
||||
except IOError as e:
|
||||
print(str(e))
|
||||
|
||||
|
||||
@@ -146,6 +146,11 @@ class Python3RuntimeTests(unittest.TestCase):
|
||||
self.assertTrue(client.stream.lines[2].endswith(" 7"))
|
||||
self.assertEqual(client.stream.raw, [expected, expected, expected])
|
||||
|
||||
def test_store_info_treats_missing_document_as_normal_absence(self):
|
||||
client = object.__new__(StoreClient)
|
||||
client.stream = _Stream([_Response(4224, "Document doesn't exist")])
|
||||
self.assertIsNone(client.Info("/events/new-event"))
|
||||
|
||||
def test_calendar_share_token_uses_python3_hashlib(self):
|
||||
token = CalendarACL(None)._GetUid("calendar")
|
||||
self.assertEqual(len(token), 32)
|
||||
|
||||
@@ -567,7 +567,7 @@ class StoreClient:
|
||||
# eat the response line
|
||||
self.stream.GetResponse()
|
||||
return item
|
||||
elif r.code == 1000:
|
||||
elif r.code in (1000, 4224):
|
||||
return None
|
||||
|
||||
raise CommandError(r)
|
||||
|
||||
Reference in New Issue
Block a user