Skip to content

Commit

Permalink
ctl: Handle size properties being negative
Browse files Browse the repository at this point in the history
Spotted on GNOME OS:

    ======= Properties =======
               State: Fetching
           CurrentID: 'fc691d2fdcd5f7d44062a301888d1a86f00f48d803d1c3278915b4460e70a617'
    Traceback (most recent call last):
      File "/usr/bin/eos-updater-ctl", line 124, in name_appeared_cb
        dump_daemon_properties(proxy)
      File "/usr/bin/eos-updater-ctl", line 94, in dump_daemon_properties
        value = GLib.format_size_full(
    OverflowError: -1 not in range 0 to 18446744073709551615

This is because on GNOME OS the necessary OSTree metadata is not
available to tell eos-updater the download size and unpacked size, only
the number of bytes that have been downloaded so far:

    [gnome@linux ~]$ gdbus introspect --system --dest com.endlessm.Updater --object-path /com/endlessm/Updater --only-properties
    node /com/endlessm/Updater {
      interface com.endlessm.Updater {
        properties:
          readonly u State = 5;
          readonly s UpdateID = '2341da03b41ba5f1b11376b7d5bbb1f5ed2d2b6c093f275e0bf1a173e39a3610';
          readonly s UpdateRefspec = 'gnome-os:gnome-os/master/x86_64-user';
          readonly s OriginalRefspec = 'gnome-os:gnome-os/master/x86_64-user';
          readonly s CurrentID = 'fc691d2fdcd5f7d44062a301888d1a86f00f48d803d1c3278915b4460e70a617';
          readonly s UpdateLabel = '';
          readonly s UpdateMessage = '';
          readonly s Version = '';
          readonly x DownloadSize = -1;
          readonly x DownloadedBytes = 214456258;
          readonly x UnpackedSize = -1;
          readonly x FullDownloadSize = -1;
          readonly x FullUnpackedSize = -1;
          @org.freedesktop.DBus.Deprecated("true")
          readonly u ErrorCode = 0;
          readonly s ErrorName = '';
          readonly s ErrorMessage = '';
      };
    };
  • Loading branch information
wjt committed Aug 3, 2021
1 parent f798703 commit f7f1a5c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions eos-updater-ctl/eos-updater-ctl
Expand Up @@ -91,9 +91,12 @@ def dump_daemon_properties(proxy):
"FullUnpackedSize",
"UnpackedSize",
):
value = GLib.format_size_full(
value.get_int64(), GLib.FormatSizeFlags.LONG_FORMAT
)
if value.get_int64() >= 0:
value = GLib.format_size_full(
value.get_int64(), GLib.FormatSizeFlags.LONG_FORMAT
)
else:
value = "Unknown"

print("{:>{}}: {}".format(x, width, value))

Expand Down

0 comments on commit f7f1a5c

Please sign in to comment.