Skip to content

Commit

Permalink
Fix caching bug in Client API that would cause the section properti…
Browse files Browse the repository at this point in the history
…es to be shared between all client objects (causing the wrong endpoint to receive the calls!)
  • Loading branch information
ntninja committed Jan 4, 2019
1 parent e0d3946 commit f8bf9ee
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ipfshttpclient/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

class SectionProperty(object):
def __init__(self, cls):
self.cls = cls
self.instance = None
self.cls = cls

def __get__(self, client_object, type=None):
if not self.instance:
self.instance = self.cls(client_object)

return self.instance
try:
return client_object.__prop_objs__[self]
except AttributeError:
client_object.__prop_objs__ = {
self: self.cls(client_object)
}
return client_object.__prop_objs__[self]
except KeyError:
client_object.__prop_objs__[self] = self.cls(client_object)
return client_object.__prop_objs__[self]


class SectionBase(object):
Expand Down

0 comments on commit f8bf9ee

Please sign in to comment.