Skip to content

Commit 569729c

Browse files
authored
Merge pull request #74 from henilp105/main
fix: validation bugs
2 parents 636e025 + 04647ad commit 569729c

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

backend/check_digests.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ def check_digests(file_path: str) -> Tuple[int, bool]:
4848

4949
# Initialize error count
5050
error_count: int = 0
51-
with open(f'{file_path}model.json', 'r') as file:
52-
model = json.load(file)
51+
try:
52+
with open(f'{file_path}fpm_model.json', 'r') as file:
53+
model = json.load(file)
54+
except:
55+
return (-1, "Error reading model file.")
5356

5457
src_data: dict = model['packages'][model['package-name']]
5558
s = set()
@@ -62,7 +65,7 @@ def check_digests(file_path: str) -> Tuple[int, bool]:
6265

6366
try:
6467
# Read the content of the file
65-
with open(file_name, 'r',newline='') as file:
68+
with open(f"{file_path}{file_name}", 'r',newline='') as file:
6669
file_content: str = file.read()
6770
except:
6871
return (-1, "Error reading file content.")

backend/validate.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def process_package(packagename: str) -> Tuple[bool, Union[dict, None], str]:
7777

7878
# Clean up
7979
cleanup_command = f'rm -rf static/temp/{packagename} static/temp/{packagename}.tar.gz'
80-
run_command(cleanup_command)
80+
# run_command(cleanup_command)
81+
print(result)
8182

8283
if result[0]==-1:
8384
# Package verification failed
@@ -99,11 +100,11 @@ def validate() -> None:
99100
None
100101
"""
101102
# packages = db.packages.find({"versions": {"$elemMatch": {"isVerified": False}}}) # find packages with unverified versions
102-
packages = db.packages.find({"isVerified": False})
103+
packages = db.packages.find({"is_verified": False})
103104
packages = list(packages)
104105
for package in packages:
105106
for i in package['versions']:
106-
if 'isVerified' in i.keys() and i['isVerified'] == False:
107+
if 'is_verified' in i.keys() and i['is_verified'] == False:
107108
try:
108109
tarball = file_storage.get(ObjectId(i['oid']))
109110
except NoFile:
@@ -118,6 +119,7 @@ def validate() -> None:
118119
update_data['isVerified'] = False
119120
update_data['unabletoVerify'] = True
120121
print("Package tests failed for " + packagename)
122+
print(result)
121123
else:
122124
print("Package tests success for " + packagename)
123125
update_data['isVerified'] = True

0 commit comments

Comments
 (0)