Merge pull request #5 from jminor/symlinks

Added --skip-symlinks option
This commit is contained in:
Christian Zangl 2023-01-09 22:33:50 +01:00 committed by GitHub
commit 32104d46df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -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.")

View File

@ -31,6 +31,9 @@ class IndexThread:
if name[0] == ".":
continue
if os.path.isdir(path):
if self.context.skip_symlinks and os.path.islink(path):
pass
else:
dirs.append(name)
elif os.path.isfile(path):
files.append(name)

View File

@ -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