Skip to content

Commit 5b4cd7f

Browse files
committed
Fix DictView and broken account access on remote
1 parent 60286be commit 5b4cd7f

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

docs/source/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ Glossary
3232
Releases
3333
----------------------
3434

35+
v2.8.5
36+
=================
37+
- Fixed "Object not added to DAF" when accessing broken accounts from remote
38+
39+
3540
v2.8.4
3641
=================
3742
- Fixed web browser waiting time being too little when searching invite links

src/daf/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ async def schema_load_from_file() -> None:
142142

143143
trace("Restoring objects from file...", TraceLEVELS.NORMAL)
144144
with open(SHILL_LIST_BACKUP_PATH, "rb") as reader:
145-
accounts = convert.convert_from_semi_dict(pickle.load(reader))
145+
accounts: List[client.ACCOUNT] = convert.convert_from_semi_dict(pickle.load(reader))
146146

147147
trace("Updating accounts.", TraceLEVELS.DEBUG)
148148
for account in accounts:
@@ -156,6 +156,8 @@ async def schema_load_from_file() -> None:
156156
TraceLEVELS.ERROR, exc
157157
)
158158
finally:
159+
# Save ID regardless if we failed result otherwise we cannot access though remote
160+
account._update_tracked_id()
159161
GLOBALS.accounts.append(account)
160162

161163
trace(f"Restored objects from file ({len(GLOBALS.accounts)} accounts).", TraceLEVELS.NORMAL)

src/daf/misc.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,15 @@ class TrackedClass(cls):
261261
if hasattr(cls, "__slots__"): # Don't break classes without slots
262262
__slots__ = ("__weakref__", "_daf_id")
263263

264-
async def initialize(self, *args, **kwargs):
265-
_r = await super().initialize(*args, **kwargs)
266-
# Update weakref dictionary
264+
def _update_tracked_id(self):
265+
"Saves ID to the tracked dictionary"
267266
value = id(self)
268267
self._daf_id = value
269268
OBJECT_ID_MAP[value] = self
269+
270+
async def initialize(self, *args, **kwargs):
271+
_r = await super().initialize(*args, **kwargs)
272+
self._update_tracked_id()
270273
return _r
271274

272275
def __getattr__(self, __key: str):

0 commit comments

Comments
 (0)