diff --git a/libraries/entropy/transceivers.py b/libraries/entropy/transceivers.py index 933961efc..99c5eefa4 100644 --- a/libraries/entropy/transceivers.py +++ b/libraries/entropy/transceivers.py @@ -53,6 +53,7 @@ class urlFetcher: self.__disallow_redirect = disallow_redirect self.__speedlimit = speed_limit # kbytes/sec self.__existed_before = False + self.localfile = None # important to have this here too self.__datatransfer = 0 @@ -104,6 +105,16 @@ class urlFetcher: def __setup_resume_support(self): + # if client uses this instance more than + # once, make sure we close previously opened + # files. + if isinstance(self.localfile, file): + try: + self.localfile.flush() + self.localfile.close() + except (IOError, OSError,): + pass + # resume support if os.path.isfile(self.__path_to_save) and \ os.access(self.__path_to_save,os.W_OK) and self.__resume: