def need_to_create_symlink(directory, checksums, filetype, symlink_path):
"""Check if we need to create a symlink for an existing file"""
# If we don't have a symlink path, we don't need to create a symlink
if symlink_path is None:
return False
pattern = EFormats.get_content(filetype)
filename, _ = get_name_and_checksum(checksums, pattern)
full_filename = os.path.join(directory, filename)
symlink_name = os.path.join(symlink_path, filename)
if os.path.islink(symlink_name):
existing_link = os.readlink(symlink_name)
if full_filename == existing_link:
return False
return True
评论列表
文章目录