Skip to content

Commit

Permalink
refacotry and update readme (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
xyb authored Nov 19, 2022
1 parent cb7be45 commit b69bf04
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# chunksum

Print FastCDC rolling hash chunks and checksums.

[![test](https://github.com/xyb/chunksum/actions/workflows/test.yml/badge.svg)](https://github.com/xyb/chunksum/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/xyb/chunksum/branch/main/graph/badge.svg?token=LR3ET0TBK2)](https://codecov.io/gh/xyb/chunksum)
[![Maintainability](https://api.codeclimate.com/v1/badges/9bd0a3b4fcefb196b2f8/maintainability)](https://codeclimate.com/github/xyb/chunksum/maintainability)
[![Latest version](https://img.shields.io/pypi/v/chunksum.svg)](https://pypi.org/project/chunksum/)
[![Support python versions](https://img.shields.io/pypi/pyversions/chunksum)](https://pypi.org/project/chunksum/)

Print FastCDC rolling hash chunks and checksums.

```
usage: chunksum [-h] [-n ALG_NAME] [-f CHUNKSUMS_FILE] [-i INCR_FILE] dir
usage: chunksum [-h] [-n ALG_NAME] [-f CHUNKSUMS_FILE] [-i INCR_FILE] [-m]
[path ...]
Print FastCDC rolling hash chunks and checksums.
positional arguments:
dir directory
path path to compute chunksums
optional arguments:
-h, --help show this help message and exit
Expand All @@ -24,6 +25,7 @@ optional arguments:
chunksum file path, `-' for standard output.
-i INCR_FILE, --incr-file INCR_FILE
incremental updates file path
-m, --multi-process same number of multi-processes as cpu
alg-name:
Format "fc[k|m|g][0-9][sha2|blake2b|blake2s][32]".
Expand All @@ -50,6 +52,8 @@ Examples:
$ chunksum /etc > ~/etc.chunksums
$ chunksum -m /etc
$ chunksum -n fcm4blake2b32 -f ~/Videos/chunksums ~/Videos
$ chunksum -n fcm4blake2b32 -f ~/chunksums -i ~/chunksums.incr ~/Videos
Expand Down
10 changes: 6 additions & 4 deletions chunksum/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
resume a previous check, or if you want to find the incremental
updates (new files) of the directory.
Examples:
$ %(prog)s /etc > ~/etc.chunksums
$ %(prog)s -m /etc
$ %(prog)s -n fcm4blake2b32 -f ~/Videos/chunksums ~/Videos
$ %(prog)s -n fcm4blake2b32 -f ~/chunksums -i ~/chunksums.incr ~/Videos
Expand Down Expand Up @@ -170,15 +171,15 @@ def main():
"-m",
"--multi-process",
action="store_true",
help="multi processing",
help="same number of multi-processes as cpu",
)
parser.add_argument(
"-x",
"--consumer-mode",
action="store_true",
help=argparse.SUPPRESS, # get paths from stdin
help=argparse.SUPPRESS, # get paths from stdin, but hide this command
)
parser.add_argument("path", nargs="*", help="path to check")
parser.add_argument("path", nargs="*", help="path to compute chunksums")
args = parser.parse_args()

no_multiprocess = False
Expand All @@ -193,6 +194,7 @@ def main():

if not paths:
parser.print_help()
sys.exit()

skip_func = None
if exists(args.chunksums_file):
Expand Down
10 changes: 5 additions & 5 deletions chunksum/mp.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def collector(queue_sums, output_file, busy, stop):
busy.clear()


def progresser(queue_progress, total):
def progress_monitor(queue_progress, total):
progress_bar = tqdm(
desc="chunksum",
total=total,
Expand Down Expand Up @@ -115,17 +115,17 @@ def compute_mp(paths, output_file, alg_name="fck4sha2", skip_func=None):

total = sum([get_total_size(path) for path in paths])

queue_progress = Queue(1000)
progress = Process(target=progresser, args=(queue_progress, total))
queue_progress = Queue(10)
progress = Process(target=progress_monitor, args=(queue_progress, total))
progress.start()

def update_progress(size):
queue_progress.put(size)

busy_events = []
consumers = []
queue_path = Queue(10)
queue_sums = Queue(10)
busy_events = []
queue_path = Queue(10)

proc_producer = Process(target=producer, args=(queue_path, iter_files(paths)))
stop_collector = Event()
Expand Down

0 comments on commit b69bf04

Please sign in to comment.