Skip to content

Commit fc4b77f

Browse files
authored
Merge pull request #1226 from jku/updater-close-file-object
Updater: close file object
2 parents 901496d + 6101817 commit fc4b77f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

tests/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def flush_log(self):
299299
break
300300

301301
if len(self.__logged_messages) > 0:
302-
title = "Test server (" + self.server + ") output:"
302+
title = "Test server (" + self.server + ") output:\n"
303303
message = [title] + self.__logged_messages
304304
self.__logger.info('| '.join(message))
305305
self.__logged_messages = []

tuf/client/updater.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,10 +1320,12 @@ def _get_target_file(self, target_filepath, file_length, file_hashes,
13201320
return file_object
13211321

13221322
except Exception as exception:
1323-
# Remember the error from this mirror, and "reset" the target file.
1323+
# Remember the error from this mirror, close tempfile if one was opened
13241324
logger.debug('Update failed from ' + file_mirror + '.')
13251325
file_mirror_errors[file_mirror] = exception
1326-
file_object = None
1326+
if file_object is not None:
1327+
file_object.close()
1328+
file_object = None
13271329

13281330
logger.debug('Failed to update ' + repr(target_filepath) + ' from'
13291331
' all mirrors: ' + repr(file_mirror_errors))

0 commit comments

Comments
 (0)