-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get all Public Folders #1300
Comments
I think this is connected to the issue reported in #1273. I don't have access to a test account with public folders, so I would suggest to debug this as described in #1273 (comment) Please note that it would help if you debug from commit f65079f which is still unreleased, since there were changes related to public folders in that commit. |
@ecederstrand I think it's somehow related because appeared about the same time, but not our problem. We work with public folders and can't get a list of all IPM folders. I also noticed that the code I tried the commit you specified, but it's still an empty generator. |
Ok. Adding a breakpoint in |
Actually, there's a slight possibility that d9035d0 fixes this. Can you give it a try? |
Thank you very much for your involvement in our problem, but it still doesn't solve it. |
@dtalkachou Did you find a solution to this? Is it apparent in all exchangelib versions, or is there a certain one that exhibits the error? |
No, I haven't. It's not dependent on the version. It returns an empty generator since somewhen. |
Hi @ecederstrand, Any advice for further investigation would be very much appreciated! |
Hi @iglimanaj, Thanks for the additional information! Interesting that exchangelib/exchangelib/folders/roots.py Line 101 in c310c65
You could add a breakpoint there and check what the child and parent folder ID's are in your case. |
Thanks for the hint @ecederstrand! exchangelib/exchangelib/folders/roots.py Line 99 in c310c65
So, the problem must be somewhere else? 🤔 |
Weird. We ask for the |
Yes, that field ist being requested and is also part of the response. |
exchangelib/exchangelib/folders/base.py Line 869 in c310c65
It ends up calling exchangelib/exchangelib/folders/roots.py Line 72 in c310c65
_folders_map .
You'll either need to trace the code into those methods to see what's going on. |
I set the breakpoints according to your recommendations and realized that parent_folder_id is set to a value which cannot be found in I get for example the following
And for a first level folder in
the according
There is clearly a mismatch.. |
Ah, maybe what happens is that You could try a patch like this: --- a/exchangelib/folders/roots.py
+++ b/exchangelib/folders/roots.py
@@ -332,6 +332,17 @@ class PublicFoldersRoot(RootOfHierarchy):
if self._distinguished_id:
self._distinguished_id.mailbox = None # See DistinguishedFolderId.clean()
+ @property
+ def _folders_map(self):
+ # Top-level public folders may point to the root folder of the owning account and not the public folders root
+ # of this account. This breaks the assumption of get_children(). Fix it by overwriting the parent folder.
+ fix_parents = self._subfolders is None
+ res = super()._folders_map
+ if fix_parents:
+ with self._subfolders_lock:
+ for f in res.values():
+ if f.id != self.id:
+ f.parent = self
+ return res
+
def get_children(self, folder):
# EWS does not allow deep traversal of public folders, so self._folders_map will only populate the top-level
# subfolders. To traverse public folders at arbitrary depth, we need to get child folders on demand. |
Available as #1316 |
Reply to #1300 (comment) @ecederstrand first of all these two changes are necessary. (I could not push in your branch) Then the following error occurred:
|
Sorry about that. Fixed now. |
Alright, thx! The problem stated above is present anyways |
Fixed |
I now can retrieve the folders. Great. I will test in another environment to double check and let you know. Huge thanks! @ecederstrand |
I tested in different environments, as promised. The fix in the pull request looks everywhere fine! @ecederstrand is it possible to make a new tag/release, once the pull request is merged? |
v5.4.1 is now out. |
Previously we retrieved all public folders for an account by
account.public_folders_root.root.children
. But it doesn't work for about three weeks, it returns an empty generator. Even thoughaccount.public_foolders_root.child_folder_count
returns the number that matches real public folder numbers, we still cannot find a way to iterate through all of the IPM folders as we did before. We use version 4.7.2 but don't mind switching if it helps. Does anyone can help us?The text was updated successfully, but these errors were encountered: