From a810033a965bba1e1bfd2341373bb059d37f5473 Mon Sep 17 00:00:00 2001 From: Will Date: Tue, 30 May 2017 20:19:31 -0400 Subject: [PATCH] updated to open the destination file inside of a try/except block --- blockstack_client/backend/drivers/sia.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/blockstack_client/backend/drivers/sia.py b/blockstack_client/backend/drivers/sia.py index acafb9d70e..0a795605aa 100644 --- a/blockstack_client/backend/drivers/sia.py +++ b/blockstack_client/backend/drivers/sia.py @@ -227,19 +227,25 @@ def download(key): contents = None - downloaded = open(destination) + downloaded = None try: - os.remove(destination) + downloaded = open(destination) except Exception as e: log.exception(e) try: - contents = downloaded.read() - downloaded.close() + os.remove(destination) except Exception as e: log.exception(e) + if downloaded is not None: + try: + contents = downloaded.read() + downloaded.close() + except Exception as e: + log.exception(e) + return contents except Exception as e: log.exception(e)