Prevent listing modules <= 40 bytes uncompressed

This prevents `list-*` from printing any module whose uncompressed size
is 40 bytes or less.

I have found a couple of modules that are exactly 40 bytes, and they
include no files, only empty directories. If any user tries to install
these modules, they will think that aqt failed to install the module
without printing any error message. I prefer to avoid this issue
by preventing `aqt list-*` from printing them.

`aqt install-*` is unaffected by this change, and it can still install
modules that contain no files. It is likely that we will need to print
a warning when this occurs.

If any user disagrees with the threshold value of 40 bytes, they are
free to adjust that value to their liking in `settings.ini`.
This commit is contained in:
David Dalcino
2021-11-26 14:04:10 -08:00
parent b8ff63da2d
commit d6a6f79740
5 changed files with 30 additions and 4 deletions

View File

@@ -376,6 +376,15 @@ class SettingsClass:
def print_stacktrace_on_error(self): def print_stacktrace_on_error(self):
return self.config.getboolean("aqt", "print_stacktrace_on_error", fallback=False) return self.config.getboolean("aqt", "print_stacktrace_on_error", fallback=False)
@property
def min_module_size(self):
"""
Some modules in the Qt repository contain only empty directories.
We have found that these modules are no more than 40 bytes after decompression.
This setting is used to filter out these empty modules in `list-*` output.
"""
return self.config.getint("aqt", "min_module_size", fallback=41)
Settings = SettingsClass() Settings = SettingsClass()

View File

@@ -624,9 +624,13 @@ class MetadataFactory:
@staticmethod @staticmethod
def _has_nonempty_downloads(element: ElementTree.Element) -> bool: def _has_nonempty_downloads(element: ElementTree.Element) -> bool:
"""Returns True if the element has an empty '<DownloadableArchives/>' tag""" """Returns True if the element has a nonempty '<DownloadableArchives/>' tag"""
downloads = element.find("DownloadableArchives") downloads = element.find("DownloadableArchives")
return downloads is not None and downloads.text update_file = element.find("UpdateFile")
if downloads is None or update_file is None:
return False
uncompressed_size = int(update_file.attrib["UncompressedSize"])
return downloads.text and uncompressed_size >= Settings.min_module_size
def _get_qt_version_str(self, version: Version) -> str: def _get_qt_version_str(self, version: Version) -> str:
"""Returns a Qt version, without dots, that works in the Qt repo urls and Updates.xml files""" """Returns a Qt version, without dots, that works in the Qt repo urls and Updates.xml files"""

View File

@@ -7,6 +7,7 @@ baseurl: https://download.qt.io
print_stacktrace_on_error: False print_stacktrace_on_error: False
always_keep_archives: False always_keep_archives: False
archive_download_location: . archive_download_location: .
min_module_size: 41
[requests] [requests]
connection_timeout: 3.5 connection_timeout: 3.5

View File

@@ -22,6 +22,7 @@ A file is like as follows:
print_stacktrace_on_error: False print_stacktrace_on_error: False
always_keep_archives: False always_keep_archives: False
archive_download_location: . archive_download_location: .
min_archive_size: 41
[requests] [requests]
connection_timeout: 3.5 connection_timeout: 3.5
@@ -85,6 +86,19 @@ archive_download_location:
will be downloaded, when ``--keep`` is turned on. will be downloaded, when ``--keep`` is turned on.
You can override this location with the ``--archives-dest`` option. You can override this location with the ``--archives-dest`` option.
min_module_size:
This is the minimum decompressed size, in bytes, of the modules that aqt is permitted to list.
The authors of aqt have discovered that the Qt repository contains a few mysteriously
"empty" modules, including the examples modules for `qtlottie` and `qtquicktimeline`.
These modules consist of a single archive that contains empty directories,
and they are exactly 40 bytes when uncompressed.
The authors feel that it is not useful for ``aqt list-*`` to list these empty modules.
If you want to print these modules with ``aqt list-*``, please feel free to change
the `min_module_size` value to something less than 40.
This setting has no effect on your ability to install these modules.
``aqt install-*`` can will still install them without any warnings.
The ``[requests]`` section controls the way that ``aqt`` makes network requests. The ``[requests]`` section controls the way that ``aqt`` makes network requests.

View File

@@ -152,11 +152,9 @@
"modules": [ "modules": [
"qtcharts", "qtcharts",
"qtdatavis3d", "qtdatavis3d",
"qtlottie",
"qtnetworkauth", "qtnetworkauth",
"qtpurchasing", "qtpurchasing",
"qtquick3d", "qtquick3d",
"qtquicktimeline",
"qtscript", "qtscript",
"qtvirtualkeyboard", "qtvirtualkeyboard",
"qtwebengine" "qtwebengine"