Skip to content

Commit

Permalink
Feat: Check file hash before skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovear committed Sep 29, 2022
1 parent de56804 commit b2e1531
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,16 @@ def skip_file(self, file:dict):
# check if file exists
if not self.overwrite:
if os.path.exists(file['file_path']):
logger.info(f"Skipping: {os.path.split(file['file_path'])[1]} | File already exists")
confirm_msg = ''
if 'hash' in file['file_variables'] and file['file_variables']['hash'] != '':
local_hash = get_file_hash(file['file_path'])
if local_hash != file['file_variables']['hash']:
logger.warning(f"Corrupted file detected, remove this file and try to redownload | path: {file['file_path']} " +
f"local hash: {local_hash} server hash: {file['file_variables']['hash']}")
os.remove(file['file_path'])
return False
confirm_msg = ' hash confirmed'
logger.info(f"Skipping: {os.path.split(file['file_path'])[1]} | File already exists{confirm_msg}")
return True

# check file name extention
Expand Down

0 comments on commit b2e1531

Please sign in to comment.