Skip to content

Commit

Permalink
Check for symlinks prior to counting file as a hardlink (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
glicholas authored Jul 19, 2024
1 parent 5682307 commit d8ec093
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions modules/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,22 +536,26 @@ def __init__(self, root_dir, remote_dir):
def get_inode_count(self):
self.inode_count = {}
for file in self.root_files:
try:
inode_no = os.stat(file.replace(self.root_dir, self.remote_dir)).st_ino
except PermissionError as perm:
logger.warning(f"{perm} : file {file} has permission issues. Skipping...")
continue
except FileNotFoundError as file_not_found_error:
logger.warning(f"{file_not_found_error} : File {file} not found. Skipping...")
continue
except Exception as ex:
logger.stacktrace()
logger.error(ex)
# Only check hardlinks for files that are symlinks
if os.path.isfile(file) and os.path.islink(file):
continue
if inode_no in self.inode_count:
self.inode_count[inode_no] += 1
else:
self.inode_count[inode_no] = 1
try:
inode_no = os.stat(file.replace(self.root_dir, self.remote_dir)).st_ino
except PermissionError as perm:
logger.warning(f"{perm} : file {file} has permission issues. Skipping...")
continue
except FileNotFoundError as file_not_found_error:
logger.warning(f"{file_not_found_error} : File {file} not found. Skipping...")
continue
except Exception as ex:
logger.stacktrace()
logger.error(ex)
continue
if inode_no in self.inode_count:
self.inode_count[inode_no] += 1
else:
self.inode_count[inode_no] = 1

def nohardlink(self, file, notify, ignore_root_dir):
"""
Expand Down

0 comments on commit d8ec093

Please sign in to comment.