misc improvements

This commit is contained in:
Christian Zangl 2024-01-10 20:28:24 +01:00
parent 69582fa16e
commit 51b5964224
No known key found for this signature in database
GPG Key ID: 6D468AC36E2A4B3D
4 changed files with 21 additions and 4 deletions

View File

@ -91,8 +91,8 @@ options:
-l FILE, --log-file FILE -l FILE, --log-file FILE
write to a logfile if specified write to a logfile if specified
--log-verbose verbose logging --log-verbose verbose logging
--index-name NAME filename where chkbit stores its hashes (default: .chkbit) --index-name NAME filename where chkbit stores its hashes, needs to start with '.' (default: .chkbit)
--ignore-name NAME filename that chkbit reads its ignore list from (default: .chkbitignore) --ignore-name NAME filename that chkbit reads its ignore list from, needs to start with '.' (default: .chkbitignore)
-w N, --workers N number of workers to use (default: 5) -w N, --workers N number of workers to use (default: 5)
--plain show plain status instead of being fancy --plain show plain status instead of being fancy
-q, --quiet quiet, don't show progress/information -q, --quiet quiet, don't show progress/information
@ -140,6 +140,8 @@ Add a `.chkbitignore` file containing the names of the files/directories you wis
- `[!seq]` matches any character not in seq - `[!seq]` matches any character not in seq
- lines starting with `#` are skipped - lines starting with `#` are skipped
- lines starting with `/` are only applied to the current directory - lines starting with `/` are only applied to the current directory
- you can use `path/sub/name` to ignore a file/directory in a sub path
- hidden files (starting with a `.`) are ignored by default
## FAQ ## FAQ

View File

@ -27,6 +27,11 @@ class Context:
self.index_filename = index_filename self.index_filename = index_filename
self.ignore_filename = ignore_filename self.ignore_filename = ignore_filename
if not index_filename.startswith("."):
raise Exception("The index filename must start with a dot!")
if not ignore_filename.startswith("."):
raise Exception("The ignore filename must start with a dot!")
# the input queue is used to distribute the work # the input queue is used to distribute the work
# to the index threads # to the index threads
self.input_queue = queue.Queue() self.input_queue = queue.Queue()
@ -48,3 +53,6 @@ class Context:
def end_input(self): def end_input(self):
self.input_queue.put(None) self.input_queue.put(None)
def is_chkbit_file(self, name):
return name in [self.index_filename, self.ignore_filename]

View File

@ -25,6 +25,10 @@ class IndexThread:
for name in os.listdir(path=iitem.path): for name in os.listdir(path=iitem.path):
path = os.path.join(iitem.path, name) path = os.path.join(iitem.path, name)
if name[0] == ".": if name[0] == ".":
if self.context.show_ignored_only and not self.context.is_chkbit_file(
name
):
self.context.log(Status.IGNORE, path)
continue continue
if os.path.isdir(path): if os.path.isdir(path):
if self.context.skip_symlinks and os.path.islink(path): if self.context.skip_symlinks and os.path.islink(path):

View File

@ -302,14 +302,14 @@ class Main:
metavar="NAME", metavar="NAME",
type=str, type=str,
default=".chkbit", default=".chkbit",
help="filename where chkbit stores its hashes (default: .chkbit)", help="filename where chkbit stores its hashes, needs to start with '.' (default: .chkbit)",
) )
parser.add_argument( parser.add_argument(
"--ignore-name", "--ignore-name",
metavar="NAME", metavar="NAME",
type=str, type=str,
default=".chkbitignore", default=".chkbitignore",
help="filename that chkbit reads its ignore list from (default: .chkbitignore)", help="filename that chkbit reads its ignore list from, needs to start with '.' (default: .chkbitignore)",
) )
parser.add_argument( parser.add_argument(
@ -376,6 +376,9 @@ def main():
except KeyboardInterrupt: except KeyboardInterrupt:
print("abort") print("abort")
sys.exit(1) sys.exit(1)
except Exception as e:
print(e, file=sys.stderr)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":