diff --git a/src/studip.py b/src/studip.py index 8265b19..c6d12be 100755 --- a/src/studip.py +++ b/src/studip.py @@ -143,11 +143,14 @@ class Studip: #total_size = int(rsp2.headers.get('content-length', 0)) log.info('downloading ' + doc_name) #progbar = tqdm(total=total_size, unit='iB', unit_scale=True) - with open(doc_name, 'wb') as doc_file: - for chunk in rsp2.iter_content(self.CHUNK_SIZE): - #progbar.update(len(chunk)) - doc_file.write(chunk) - self.db.set_last_file_dl(str(doc), str(int(time.time()))) + try: + with open(doc_name, 'wb') as doc_file: + for chunk in rsp2.iter_content(self.CHUNK_SIZE): + #progbar.update(len(chunk)) + doc_file.write(chunk) + self.db.set_last_file_dl(str(doc), str(int(time.time()))) + except: + log.CRITICAL("Error while writing to the file " + doc_name) def get_subdirs(self, folder): """Get all the subdirectories of a given folder.