diff --git a/nxdrive/gui/api.py b/nxdrive/gui/api.py index e46a925e30..81f3506cd6 100644 --- a/nxdrive/gui/api.py +++ b/nxdrive/gui/api.py @@ -564,20 +564,20 @@ def get_disk_space_info_to_width( - Size of space used by other applications converted to percentage of the width. - Global size of synchronized files converted to percentage of the width. """ - engine = self._get_engine(uid) - - synced = engine.dao.get_global_size() if engine else 0 - used, free = disk_space(path) - used_without_sync = used - synced - total = used + free - result = self._balance_percents( - { - "free": free * width / total, - "used_without_sync": used_without_sync * width / total, - "synced": synced * width / total, - } - ) - return [result["free"], result["used_without_sync"], result["synced"]] + if engine := self._get_engine(uid): + + synced = engine.dao.get_global_size() if engine else 0 + used, free = disk_space(path) + used_without_sync = used - synced + total = used + free + result = self._balance_percents( + { + "free": free * width / total, + "used_without_sync": used_without_sync * width / total, + "synced": synced * width / total, + } + ) + return [result["free"], result["used_without_sync"], result["synced"]] def _balance_percents(self, result: Dict[str, float], /) -> Dict[str, float]: """Return an altered version of the dict in which no value is under a minimum threshold."""