From d46aef8fcb291980763d30bb67fa32b7d3e73c51 Mon Sep 17 00:00:00 2001 From: GaspardCulis Date: Fri, 5 Jan 2024 17:53:22 +0100 Subject: [PATCH] sync: Added BOT_MISSING SyncStatus --- sync | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sync b/sync index 5f38d3e..beed8d9 100755 --- a/sync +++ b/sync @@ -11,6 +11,7 @@ class SyncStatus: DIFF = 2 SRC_MISSING = 3 DEST_MISSING = 4 + BOTH_MISSING = 5 # https://stackoverflow.com/a/287944 @@ -93,7 +94,9 @@ def get_sync_status(fd: tuple[str, str]) -> SyncStatus: return True return any([has_differences(subdcmp) for subdcmp in dcmp.subdirs.values()]) - if not os.path.exists(f1): + if not (os.path.exists(f1) or os.path.exists(f2)): + return SyncStatus.BOTH_MISSING + elif not os.path.exists(f1): return SyncStatus.SRC_MISSING elif not os.path.exists(f2): return SyncStatus.DEST_MISSING @@ -122,6 +125,8 @@ def list_files(reverse: bool = False) -> list[int]: elif status == SyncStatus.DEST_MISSING: f1_c = bcolors.RED if reverse else f1_c f2_c = bcolors.RED if not reverse else f2_c + elif status == SyncStatus.BOTH_MISSING: + f1_c, f2_c = bcolors.RED, bcolors.RED print( f"{bcolors.PURPLE}{i} {f1_c}{f[int(reverse)]} {bcolors.ENDC}-> {f2_c}{f[int(not reverse)]}{bcolors.ENDC}"