Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 024f261

Browse files
committed
get_latest_hash() function now checks for just the single file with new gitub api link
1 parent 06fbcd6 commit 024f261

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

commands/publish_dafsa.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import requests
2-
from requests.exceptions import HTTPError
32
import tempfile
3+
from requests.exceptions import HTTPError
4+
5+
import os
46
import subprocess
57
from kinto_http import Client, KintoException
6-
import os
78

8-
COMMIT_HASH_URL = "https://api.github.com/repos/publicsuffix/list/commits/master"
9+
COMMIT_HASH_URL = (
10+
"https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat"
11+
)
912

1013
LIST_URL = (
1114
"https://raw.githubusercontent.com/publicsuffix/list/master/public_suffix_list.dat"
@@ -41,12 +44,7 @@ def inner(*args, **kwargs):
4144
def get_latest_hash():
4245
response = requests.get(COMMIT_HASH_URL)
4346
response.raise_for_status()
44-
45-
modified_files = response.json()["files"]
46-
for f in modified_files:
47-
if f["filename"] == "public_suffix_list.dat":
48-
return response.json()["sha"]
49-
return ""
47+
return response.json()[0]["sha"]
5048

5149

5250
@handle_request_errors
@@ -81,9 +79,11 @@ def make_dafsa_and_publish(client, latest_hash):
8179
output_binary_path = os.path.join(tmp, output_binary_name)
8280

8381
# Make the DAFSA
84-
subprocess.run(
82+
run = subprocess.run(
8583
["python3", prepare_tlds_py_path, raw_psl_path, output_binary_path]
8684
)
85+
if run.returncode != 0:
86+
return 1
8787

8888
subprocess.run(["ls", tmp])
8989

@@ -115,7 +115,7 @@ def publish_dafsa():
115115
# print(e)
116116

117117
# if record["data"]["latest-commit-hash"] == latest_hash:
118-
# return 0
118+
# return 1
119119
# else:
120120
make_dafsa_and_publish(client, latest_hash)
121121

0 commit comments

Comments
 (0)