Skip to content

Commit f810f51

Browse files
committed
INTEGRITY: Fix incorrect fileset redirection issue in logs.
1 parent 4222dde commit f810f51

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

fileset.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ def fileset():
8888
# Get the id from the GET parameters, or use the minimum id if it's not provided
8989
id = request.args.get("id", default=min_id, type=int)
9090

91+
# Check if the id exists in the fileset table
92+
cursor.execute("SELECT id FROM fileset WHERE id = %s", (id,))
93+
if cursor.rowcount == 0:
94+
# If the id doesn't exist, get a new id from the history table
95+
cursor.execute(
96+
"SELECT fileset FROM history WHERE oldfileset = %s", (id,)
97+
)
98+
id = cursor.fetchone()["fileset"]
99+
return redirect(f"/fileset?id={id}")
100+
91101
# Get the maximum id from the fileset table
92102
cursor.execute("SELECT MAX(id) FROM fileset")
93103
max_id = cursor.fetchone()["MAX(id)"]
@@ -100,15 +110,6 @@ def fileset():
100110
# Ensure the id is between the minimum and maximum id
101111
id = max(min_id, min(id, max_id))
102112

103-
# Check if the id exists in the fileset table
104-
cursor.execute("SELECT id FROM fileset WHERE id = %s", (id,))
105-
if cursor.rowcount == 0:
106-
# If the id doesn't exist, get a new id from the history table
107-
cursor.execute(
108-
"SELECT fileset FROM history WHERE oldfileset = %s", (id,)
109-
)
110-
id = cursor.fetchone()["fileset"]
111-
112113
# Get the history for the current id
113114
cursor.execute(
114115
"SELECT `timestamp`, oldfileset, log FROM history WHERE fileset = %s ORDER BY `timestamp`",

0 commit comments

Comments
 (0)