Skip to content

Commit

Permalink
misc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
laktak committed Jan 10, 2024
1 parent 69582fa commit 51b5964
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ options:
-l FILE, --log-file FILE
write to a logfile if specified
--log-verbose verbose logging
--index-name NAME filename where chkbit stores its hashes (default: .chkbit)
--ignore-name NAME filename that chkbit reads its ignore list from (default: .chkbitignore)
--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, needs to start with '.' (default: .chkbitignore)
-w N, --workers N number of workers to use (default: 5)
--plain show plain status instead of being fancy
-q, --quiet quiet, don't show progress/information
Expand Down Expand Up @@ -140,6 +140,8 @@ Add a `.chkbitignore` file containing the names of the files/directories you wis
- `[!seq]` matches any character not in seq
- lines starting with `#` are skipped
- 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

Expand Down
8 changes: 8 additions & 0 deletions chkbit/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def __init__(
self.index_filename = index_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
# to the index threads
self.input_queue = queue.Queue()
Expand All @@ -48,3 +53,6 @@ def add_input(self, path: str, *, ignore: Optional[chkbit.Ignore] = None):

def end_input(self):
self.input_queue.put(None)

def is_chkbit_file(self, name):
return name in [self.index_filename, self.ignore_filename]
4 changes: 4 additions & 0 deletions chkbit/index_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def _process_root(self, iitem: chkbit.InputItem):
for name in os.listdir(path=iitem.path):
path = os.path.join(iitem.path, name)
if name[0] == ".":
if self.context.show_ignored_only and not self.context.is_chkbit_file(
name
):
self.context.log(Status.IGNORE, path)
continue
if os.path.isdir(path):
if self.context.skip_symlinks and os.path.islink(path):
Expand Down
7 changes: 5 additions & 2 deletions chkbit_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ def run(self):
metavar="NAME",
type=str,
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(
"--ignore-name",
metavar="NAME",
type=str,
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(
Expand Down Expand Up @@ -376,6 +376,9 @@ def main():
except KeyboardInterrupt:
print("abort")
sys.exit(1)
except Exception as e:
print(e, file=sys.stderr)
sys.exit(1)


if __name__ == "__main__":
Expand Down

0 comments on commit 51b5964

Please sign in to comment.