Added --skip-symlinks option
This commit is contained in:
parent
73c5a9ec53
commit
89df568735
@ -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.")
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user