Merge pull request #1226 from jku/updater-close-file-object

Updater: close file object
This commit is contained in:
lukpueh 2020-11-27 12:29:08 +01:00 committed by GitHub
commit fc4b77f92c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -299,7 +299,7 @@ def flush_log(self):
break
if len(self.__logged_messages) > 0:
title = "Test server (" + self.server + ") output:"
title = "Test server (" + self.server + ") output:\n"
message = [title] + self.__logged_messages
self.__logger.info('| '.join(message))
self.__logged_messages = []

View file

@ -1320,10 +1320,12 @@ def _get_target_file(self, target_filepath, file_length, file_hashes,
return file_object
except Exception as exception:
# Remember the error from this mirror, and "reset" the target file.
# Remember the error from this mirror, close tempfile if one was opened
logger.debug('Update failed from ' + file_mirror + '.')
file_mirror_errors[file_mirror] = exception
file_object = None
if file_object is not None:
file_object.close()
file_object = None
logger.debug('Failed to update ' + repr(target_filepath) + ' from'
' all mirrors: ' + repr(file_mirror_errors))