Merge pull request #5 from jminor/symlinks
Added --skip-symlinks option
This commit is contained in:
commit
32104d46df
@ -2,12 +2,13 @@ import hashlib
|
|||||||
|
|
||||||
|
|
||||||
class Context:
|
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.verify_index = verify_index
|
||||||
self.update = update
|
self.update = update
|
||||||
self.force = force
|
self.force = force
|
||||||
self.hash_algo = hash_algo
|
self.hash_algo = hash_algo
|
||||||
|
self.skip_symlinks = skip_symlinks
|
||||||
|
|
||||||
if hash_algo not in ["md5", "sha512"]:
|
if hash_algo not in ["md5", "sha512"]:
|
||||||
raise Exception(f"{hash_algo} is unknown.")
|
raise Exception(f"{hash_algo} is unknown.")
|
||||||
|
@ -31,7 +31,10 @@ class IndexThread:
|
|||||||
if name[0] == ".":
|
if name[0] == ".":
|
||||||
continue
|
continue
|
||||||
if os.path.isdir(path):
|
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):
|
elif os.path.isfile(path):
|
||||||
files.append(name)
|
files.append(name)
|
||||||
|
|
||||||
|
@ -81,6 +81,10 @@ class Main:
|
|||||||
help="verify files in the index only (will not report new files)",
|
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(
|
parser.add_argument(
|
||||||
"-w",
|
"-w",
|
||||||
"--workers",
|
"--workers",
|
||||||
@ -133,6 +137,7 @@ class Main:
|
|||||||
self.args.update,
|
self.args.update,
|
||||||
self.args.force,
|
self.args.force,
|
||||||
self.args.algo,
|
self.args.algo,
|
||||||
|
self.args.skip_symlinks
|
||||||
)
|
)
|
||||||
|
|
||||||
# start indexing
|
# start indexing
|
||||||
|
Reference in New Issue
Block a user