Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: variable become undefined when extension not exist or connection… #868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

miurahr
Copy link
Owner

@miurahr miurahr commented Dec 24, 2024

@miurahr miurahr force-pushed the topic/miurahr/extension-may-not-exist branch from a30786b to 690f798 Compare December 24, 2024 03:27
@miurahr miurahr marked this pull request as ready for review December 24, 2024 03:27
@miurahr
Copy link
Owner Author

miurahr commented Dec 24, 2024

@tsteven4 could you please check the change?

aqt/helper.py Outdated Show resolved Hide resolved
@miurahr miurahr force-pushed the topic/miurahr/extension-may-not-exist branch from dd721f5 to 107dbc2 Compare December 24, 2024 05:28
… error

- Fixed the issue #867

Signed-off-by: Hiroshi Miura <miurahr@linux.com>
@miurahr miurahr force-pushed the topic/miurahr/extension-may-not-exist branch from 107dbc2 to 98fda2e Compare December 24, 2024 05:48
@tsteven4
Copy link
Contributor

I agree I messed this up. I have an alternative fix in process. I will submit it for consideration.

@@ -442,11 +442,12 @@ def _get_archives_base(self, name, target_packages):
try:
extensions_xml_text = self._download_update_xml(extensions_xml_url, True)
except ArchiveDownloadError:
# In case _download_update_xml ignores the hash and tries to get the url.
# In case _download_update_xml failed to get the url because of no extension.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary failure when the extension doesn't exist is ChecksumDownloadFailure, which is caught by download_update_xml. I had to modify the code to simulate getting through that and failing with an ArchiveDownloadError.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I see in #867 the OP had set INSECURE_NOT_FOR_PRODUCTION_ignore_hash: True

So I think the original comment is more accurate.

Copy link
Owner Author

@miurahr miurahr Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When _download_update_xml method failed to download sha256 checksum, it does not throw exception but set xml_hash = None and call get_url.
The exception is thrown from get_url that try to download Updates.xml itself.

So when got ArchiveDownloadError here, it means that it failed to download Update.xml not hash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming Settings.ignore_hash is False download_update_xml catches ChecksumDownloadFailure and RETURNS None. It doesn't call get_url (silent = True). This is the normal production behavior.

The OP set ignore_hash to True which behaves as you indicated.

Comment on lines +448 to +450
if extensions_xml_text:
self.logger.info("Found extension {}".format(ext))
update_xmls.append(UpdateXmls(extensions_target_folder, extensions_xml_text))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this into the try block but putting them in the else block may be preferred. There are two places in metadata.py
related to "except (ChecksumDownloadFailure, ArchiveDownloadError)" where I also added additional code to the try block where an else block might be preferred.

Copy link
Contributor

@tsteven4 tsteven4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are in here it would be good to change

for ext in ["qtwebengine", "qtpdf"]:

to
for ext in QtRepoProperty.known_extensions(self.version):
so we only have the list of extensions in one place.

@miurahr
Copy link
Owner Author

miurahr commented Dec 25, 2024

While you are in here it would be good to change

It is out of scope of the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants