Skip to content

Commit 53fabac

Browse files
committed
python: Ensure 'size' & 'download-size' are reported as unknown if None
If the 'size' and 'download-size' are None, set them to MAXUINT64 to ensure they get reported as 'unknown' in pkcon and other frontends.
1 parent 8007172 commit 53fabac

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/python/packagekit/backend.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import traceback
2929
import os.path
3030

31+
from gi.repository import GLib
32+
3133
from .enums import *
3234

3335
PACKAGE_IDS_DELIM = '&'
@@ -244,6 +246,13 @@ def details(self, package_id, summary, package_license, group, desc, url, bytes,
244246
@param bytes: The size of the package, in bytes
245247
@param download_bytes: The download size of the package, in bytes
246248
'''
249+
250+
# Ensure sizes report as 'unknown' in pkcon if not reported
251+
if bytes is None:
252+
bytes = GLib.MAXUINT64
253+
if download_bytes is None:
254+
download_bytes = GLib.MAXUINT64
255+
247256
sys.stdout.write(_to_utf8("details\t%s\t%s\t%s\t%s\t%s\t%s\t%ld\t%ld\n" % (package_id, summary, package_license, group, desc, url, bytes, download_bytes)))
248257
sys.stdout.flush()
249258

0 commit comments

Comments
 (0)