Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/357'
Browse files Browse the repository at this point in the history
* origin/pr/357:
  Update size on disk in Qube Manager occassionally
  • Loading branch information
marmarek committed Nov 22, 2023
2 parents 124b881 + df5748c commit a22ddef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion qubesmanager/qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,10 @@ def __init__(self, qt_app, qubes_app, dispatcher, _parent=None):
self.progress = None

self.check_updates()
self.size_on_disk_timer = QTimer()
self.size_on_disk_timer.timeout.connect(self.update_running_size)
self.size_on_disk_timer.setInterval(1000 * 60 * 5) # every 5 mins
self.size_on_disk_timer.start()

def change_template(self, template):
selected_vms = self.get_selected_vms()
Expand Down Expand Up @@ -1067,6 +1071,12 @@ def check_updates(self, info=None):
except exc.QubesDaemonAccessError:
return

def update_running_size(self, *_args):
for vm in self.qubes_app.domains:
if vm.is_running():
self.qubes_cache.get_vm(qid=vm.qid).update(
update_size_on_disk=True, event='disk_size')

def on_domain_added(self, _submitter, _event, vm, **_kwargs):
try:
domain = self.qubes_app.domains[vm]
Expand All @@ -1085,7 +1095,8 @@ def on_domain_removed(self, _submitter, _event, **kwargs):

def on_domain_status_changed(self, vm, event, **_kwargs):
try:
self.qubes_cache.get_vm(qid=vm.qid).update(event=event)
self.qubes_cache.get_vm(qid=vm.qid).update(update_size_on_disk=True,
event=event)
if vm.klass in {'TemplateVM'}:
for appvm in vm.appvms:
self.qubes_cache.get_vm(qid=appvm.qid).\
Expand Down

0 comments on commit a22ddef

Please sign in to comment.