We have implemented an exists() method in the DirSrv class to check wether an instance exists or not, but instead of using it, we have manual checks in a few places. Let's not repeat ourselfs and replace this code.
NOTICE: There's this line that checks len(props) against 0 instead of 1. https://pagure.io/lib389/blob/master/f/lib389/__init__.py#_922
Can this be safely replaced by a call to exists()?
Also, I replaced this:
props = self.list() assert len(props) == 1 self.sroot = props[0][CONF_SERVER_DIR]
With this:
assert self.exists() self.sroot = self.list()[0][CONF_SERVER_DIR]
While logically equivalent, with the second one we have 2 calls to self.list().
Thoughts on all this?
<img alt="0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" src="/lib389/issue/raw/files/891491809f5254543126cf12c581d52e756b8aa0f402a8a6dd1ffd51a8b3bb75-0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" />
I think this looks okay myself. Have you run the tests with it?
Metadata Update from @ilias95: - Issue assigned to ilias95
Yes, I have run the tests and they all pass except for some errors and failures that I had anyway due to other bugs. I also attach a new patch implementing the change I mentioned in the notice. The tests again pass. <img alt="0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" src="/lib389/issue/raw/files/2981bdb171cc73b318f778d435fe116216ed7105873cea67c930c502f7fa85ed-0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" />
Metadata Update from @ilias95: - Custom field Review Status adjusted to review
Sorry, I had a typo in the commit message. Fixed.
<img alt="0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" src="/lib389/issue/raw/files/188e95c5b473cf138a48a5f0e3946f69b13706dd02f5de128006493c031bc9f3-0001-Ticket-23-Use-DirSrv.exists-instead-of-manually-chec.patch" />
Looks good to me! Thanks for the improvement.
commit ca2fdc5 To ssh://git@pagure.io/lib389.git de3d644..ca2fdc5 master -> master
Metadata Update from @firstyear: - Custom field Review Status adjusted to ack (was: review) - Issue close_status updated to: Fixed - Issue status updated to: Closed (was: Open)
Login to comment on this ticket.