return False by default when there are permission issues

in noHL
This commit is contained in:
bobokun 2023-05-20 11:19:30 -04:00
parent 07b7350b60
commit e07c3e417b
No known key found for this signature in database
GPG key ID: B73932169607D927

View file

@ -354,6 +354,7 @@ class CheckHardLinks:
This fixes the bug in #192
"""
check_for_hl = True
try:
if os.path.isfile(file):
logger.trace(f"Checking file: {file}")
logger.trace(f"Checking file inum: {os.stat(file).st_ino}")
@ -390,6 +391,16 @@ class CheckHardLinks:
largest_file_size * threshold
):
check_for_hl = False
except PermissionError as perm:
logger.warning(f"{perm} : file {file} has permission issues.")
return False
except FileNotFoundError as file_not_found_error:
logger.warning(f"{file_not_found_error} : File {file} not found.")
return False
except Exception as ex:
logger.stacktrace()
logger.error(ex)
return False
return check_for_hl