Skip to content

Commit

Permalink
Fixed crash when pool goes offline, fixes #152
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Apr 25, 2024
1 parent a59ea1e commit 2c5ed51
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions custom_components/truenas/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,13 +782,16 @@ def get_pool(self) -> None:

self.ds["pool"][uid].pop("root_dataset")

self.ds["pool"][uid]["usage"] = round(
(
self.ds["pool"][uid]["available_gib"]
/ self.ds["pool"][uid]["total_gib"]
if self.ds["pool"][uid]["total_gib"] > 0:
self.ds["pool"][uid]["usage"] = round(
(
self.ds["pool"][uid]["available_gib"]
/ self.ds["pool"][uid]["total_gib"]
)
* 100
)
* 100
)
else:
self.ds["pool"][uid]["usage"] = 0

# ---------------------------
# get_dataset
Expand Down

0 comments on commit 2c5ed51

Please sign in to comment.