From 3c8b46b38a71795631ac482e9d878ca9941f845f Mon Sep 17 00:00:00 2001 From: Sepalani Date: Sun, 6 Jan 2019 17:32:48 +0400 Subject: [PATCH] DLS1: Fix filters on count action w/o list files --- other/dlc.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/other/dlc.py b/other/dlc.py index 2ecab9c..aa02611 100644 --- a/other/dlc.py +++ b/other/dlc.py @@ -150,20 +150,17 @@ def download_count(dlc_path, post): """Handle download count request.""" if post["gamecd"] in gamecodes_return_random_file: return "1" - elif os.path.exists(dlc_path): + if os.path.exists(dlc_path): + attr1 = post.get("attr1", None) + attr2 = post.get("attr2", None) + attr3 = post.get("attr3", None) if os.path.isfile(os.path.join(dlc_path, "_list.txt")): - attr1 = post.get("attr1", None) - attr2 = post.get("attr2", None) - attr3 = post.get("attr3", None) - dlc_file = safeloadfi(dlc_path, "_list.txt") ls = filter_list(dlc_file, attr1, attr2, attr3) - count = get_file_count(ls) - else: - count = len(os.listdir(dlc_path)) - return "%d" % count - else: - return "0" + return "{}".format(get_file_count(ls)) + elif attr1 is None and attr2 is None and attr3 is None: + return "{}".format(len(os.listdir(dlc_path))) + return "0" def download_size(dlc_path, name):