kopia lustrzana https://github.com/snarfed/bridgy-fed
bug fix for Protocol.load with remote=False and existing empty Object
fixes https://console.cloud.google.com/errors/detail/CI7JpJWfoff1Ew;time=P30D?project=bridgy-federatedpull/553/head
rodzic
21ab9e34ed
commit
f5133b3ee3
|
@ -645,6 +645,9 @@ class Protocol:
|
|||
|
||||
if remote is True:
|
||||
logger.info(' remote=True, forced refresh requested')
|
||||
elif remote is False:
|
||||
logger.info(' remote=False, {"empty" if obj else "not"} in datastore')
|
||||
return obj
|
||||
|
||||
if obj:
|
||||
obj.clear()
|
||||
|
@ -652,9 +655,6 @@ class Protocol:
|
|||
else:
|
||||
if local:
|
||||
logger.info(' not in datastore')
|
||||
if remote is False:
|
||||
logger.info(' remote=False; returning None')
|
||||
return None
|
||||
obj = Object(id=id)
|
||||
obj.new = True
|
||||
obj.changed = False
|
||||
|
|
|
@ -241,6 +241,12 @@ class ProtocolTest(TestCase):
|
|||
self.assert_entities_equal(obj, Fake.load('foo', remote=False))
|
||||
self.assertEqual([], Fake.fetched)
|
||||
|
||||
def test_Protocol_load_remote_false_existing_object_empty(self):
|
||||
obj = Object(id='foo')
|
||||
obj.put()
|
||||
del protocol.objects_cache['foo']
|
||||
self.assert_entities_equal(obj, Protocol.load('foo', remote=False))
|
||||
|
||||
def test_local_false_missing(self):
|
||||
with self.assertRaises(requests.HTTPError) as e:
|
||||
Fake.load('foo', local=False)
|
||||
|
|
Ładowanie…
Reference in New Issue