From 4b1ae5f4aa9488ec4b6670813d0972aa3233f740 Mon Sep 17 00:00:00 2001 From: SonarBeserk Date: Thu, 3 Nov 2022 01:22:33 -0400 Subject: [PATCH] Revert "Pull in pr #45's changes to use temp files to prevent corruption" This reverts commit 259dbde4fc9d728b2daa17911a68f42c455efc85. --- humblebundle_downloader/download_library.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/humblebundle_downloader/download_library.py b/humblebundle_downloader/download_library.py index aafdc79..5b2dd86 100644 --- a/humblebundle_downloader/download_library.py +++ b/humblebundle_downloader/download_library.py @@ -59,7 +59,6 @@ def __init__(self, library_path, cookie_path=None, cookie_auth=None, def start(self): self.cache_file = os.path.join(self.library_path, '.cache.json') - self.cache_file_temp = os.path.join(self.library_path, '.tmp.cache.json') self.cache_data = self._load_cache_data(self.cache_file) self.purchase_keys = self.purchase_keys if self.purchase_keys else self._get_purchase_keys() # noqa: E501 @@ -311,14 +310,11 @@ def _update_cache_data(self, cache_file_key, file_info): # quits it can keep track of the progress # Note: Only safe because of single thread, # need to change if refactor to multi threading - with open(self.cache_file_temp, 'w') as outfile: + with open(self.cache_file, 'w') as outfile: json.dump( self.cache_data, outfile, sort_keys=True, indent=4, ) - - outfile.close() #explicitly close outfile and flush output buffer. - os.rename(self.cache_file_temp,self.cache_file) #rename temp file to real file. def _process_download(self, open_r, cache_file_key, file_info, local_filename, rename_str=None):