From a4a67b2b797ef575b42a5582e498530d74d0b71a Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 15 Nov 2023 15:02:23 -0500 Subject: [PATCH] Prevent div by zero --- libretranslate/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretranslate/app.py b/libretranslate/app.py index e6875eb..bad5db1 100644 --- a/libretranslate/app.py +++ b/libretranslate/app.py @@ -766,7 +766,7 @@ def create_app(args): # set the cost of the request to N = bytes / char_limit, which is # roughly equivalent to a batch process of N batches assuming # each batch uses all available limits - if args.char_limit != -1: + if args.char_limit > 0: request.req_cost = max(1, int(os.path.getsize(filepath) / args.char_limit)) translated_file_path = argostranslatefiles.translate_file(src_lang.get_translation(tgt_lang), filepath)