Handle sys file being a directory while dotfile is file

This commit is contained in:
ItsDrike 2022-10-29 20:34:42 +02:00
parent a3e01caebf
commit 8536bfa688
No known key found for this signature in database
GPG key ID: B014E761034AF742

View file

@ -28,6 +28,7 @@ class DiffStatus(Enum):
UNEXPECTED_SYMLINK = auto() UNEXPECTED_SYMLINK = auto()
CONTENT_DIFFERS = auto() CONTENT_DIFFERS = auto()
SYMLINK_DIFFERS = auto() SYMLINK_DIFFERS = auto()
UNEXPECTED_DIRECTORY = auto()
class FileDiff(NamedTuple): class FileDiff(NamedTuple):
@ -90,6 +91,9 @@ def compare_files(dot_file: Path, sys_file: Path) -> DiffStatus:
elif sys_file.is_symlink(): elif sys_file.is_symlink():
return DiffStatus.UNEXPECTED_SYMLINK return DiffStatus.UNEXPECTED_SYMLINK
if sys_file.is_dir():
return DiffStatus.UNEXPECTED_DIRECTORY
try: try:
if file_sum(dot_file) == file_sum(sys_file): if file_sum(dot_file) == file_sum(sys_file):
return DiffStatus.MATCH return DiffStatus.MATCH