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

bootloader dialog Release flashing not picking new release #576

Merged
merged 4 commits into from
Jan 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/cfclient/ui/dialogs/bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ def __init__(self, qtsignal_get_all_firmwares, qtsignal_get_release):
self._qtsignal_get_release = qtsignal_get_release

self._tempDirectory = tempfile.TemporaryDirectory()
self._filepath = os.path.join(self._tempDirectory.name,
'tmp.zip')

self.moveToThread(self)

def get_firmware_releases(self):
Expand Down Expand Up @@ -489,27 +488,28 @@ def _download_release(self, signal, release_name, url):
""" Downloads the given release and calls the callback signal
if successful.
"""
filepath = os.path.join(self._tempDirectory.name, release_name.split(' ')[-1])
try:
# Check if we have an old file saved and if so, ensure it's a valid
# zipfile and then call signal
with open(self._filepath, 'rb') as f:
with open(filepath, 'rb') as f:
previous_release = zipfile.ZipFile(f)
# testzip returns None if it's OK.
if previous_release.testzip() is None:
logger.info('Using same firmware-release file at'
'%s' % self._filepath)
signal.emit(release_name, self._filepath)
'%s' % filepath)
signal.emit(release_name, filepath)
return
except FileNotFoundError:
try:
# Fetch the file with a new web request and save it to
# a temporary file.
with urlopen(url) as response:
with open(self._filepath, 'wb') as release_file:
with open(filepath, 'wb') as release_file:
release_file.write(response.read())
logger.info('Created temporary firmware-release file at'
'%s' % self._filepath)
signal.emit(release_name, self._filepath)
'%s' % filepath)
signal.emit(release_name, filepath)
except URLError:
logger.warning('Failed to make web request to get requested'
' firmware-release')