diff --git a/chkbit/context.py b/chkbit/context.py index e5bb3ce..607ab73 100644 --- a/chkbit/context.py +++ b/chkbit/context.py @@ -2,12 +2,13 @@ import hashlib class Context: - def __init__(self, verify_index, update, force, hash_algo): + def __init__(self, verify_index, update, force, hash_algo, skip_symlinks): self.verify_index = verify_index self.update = update self.force = force self.hash_algo = hash_algo + self.skip_symlinks = skip_symlinks if hash_algo not in ["md5", "sha512"]: raise Exception(f"{hash_algo} is unknown.") diff --git a/chkbit/indexthread.py b/chkbit/indexthread.py index ce946bb..b55ce69 100644 --- a/chkbit/indexthread.py +++ b/chkbit/indexthread.py @@ -31,7 +31,10 @@ class IndexThread: if name[0] == ".": continue if os.path.isdir(path): - dirs.append(name) + if self.context.skip_symlinks and os.path.islink(path): + pass + else: + dirs.append(name) elif os.path.isfile(path): files.append(name) diff --git a/chkbit/main.py b/chkbit/main.py index 96afc9b..0274e8e 100644 --- a/chkbit/main.py +++ b/chkbit/main.py @@ -81,6 +81,10 @@ class Main: help="verify files in the index only (will not report new files)", ) + parser.add_argument( + "-s", "--skip-symlinks", action="store_true", help="do not follow symlinks" + ) + parser.add_argument( "-w", "--workers", @@ -133,6 +137,7 @@ class Main: self.args.update, self.args.force, self.args.algo, + self.args.skip_symlinks ) # start indexing