Merge pull request #510 from sepalani/count_attr

DLS1: Fix filters on count action w/o list files
This commit is contained in:
sepalani 2019-01-07 19:27:04 +04:00 committed by GitHub
commit 975ef50fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,20 +153,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):