Skip to content

Commit 599d2f1

Browse files
committed
INTEGRITY: Avoid adding a fileset as candidate if it was marked as partial in the same run.
1 parent cc82c6f commit 599d2f1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

db_functions.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,16 @@ def set_process(
10341034
fileset["name"], candidate_filesets, conn
10351035
)
10361036

1037+
for candidate_fileset in candidate_filesets:
1038+
with conn.cursor() as cursor:
1039+
cursor.execute(
1040+
"SELECT id FROM fileset WHERE status = 'current' AND id = %s",
1041+
(candidate_fileset),
1042+
)
1043+
result = cursor.fetchone()
1044+
if result:
1045+
candidate_filesets.remove(candidate_fileset)
1046+
10371047
(
10381048
fully_matched_filesets,
10391049
auto_merged_filesets,
@@ -1056,6 +1066,8 @@ def set_process(
10561066

10571067
# Final log
10581068
with conn.cursor() as cursor:
1069+
cursor.execute("UPDATE fileset SET status = 'partial' WHERE status = 'current'")
1070+
10591071
cursor.execute(
10601072
"SELECT COUNT(fileset) from transactions WHERE `transaction` = %s",
10611073
(transaction_id,),
@@ -1099,9 +1111,6 @@ def set_filter_by_platform(gameid, candidate_filesets, conn):
10991111
if candidate_platform in possible_platform_names:
11001112
filtered_candidate_fileset.append(candidate_fileset_id)
11011113

1102-
if len(filtered_candidate_fileset) != 0:
1103-
print(len(candidate_filesets), " ", len(filtered_candidate_fileset), "\n")
1104-
11051114
# If nothing was filtred, then it is likely, that platform information was not present, so we fallback to original list of candidates.
11061115
return (
11071116
candidate_filesets
@@ -1135,7 +1144,7 @@ def set_perform_match(
11351144
)
11361145
status = cursor.fetchone()["status"]
11371146
if status == "detection":
1138-
update_fileset_status(cursor, matched_fileset_id, "partial")
1147+
update_fileset_status(cursor, matched_fileset_id, "current")
11391148
set_populate_file(fileset, matched_fileset_id, conn, detection)
11401149
auto_merged_filesets += 1
11411150
if not skiplog:
@@ -1186,7 +1195,7 @@ def set_perform_match(
11861195
for candidate_fileset in candidate_filesets:
11871196
(is_match, _) = is_full_checksum_match(candidate_fileset, fileset, conn)
11881197
if is_match:
1189-
update_fileset_status(cursor, candidate_fileset, "partial")
1198+
update_fileset_status(cursor, candidate_fileset, "current")
11901199
set_populate_file(fileset, candidate_fileset, conn, detection)
11911200
auto_merged_filesets += 1
11921201
if not skiplog:

0 commit comments

Comments
 (0)