@@ -88,6 +88,16 @@ def fileset():
88
88
# Get the id from the GET parameters, or use the minimum id if it's not provided
89
89
id = request .args .get ("id" , default = min_id , type = int )
90
90
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
+
91
101
# Get the maximum id from the fileset table
92
102
cursor .execute ("SELECT MAX(id) FROM fileset" )
93
103
max_id = cursor .fetchone ()["MAX(id)" ]
@@ -100,15 +110,6 @@ def fileset():
100
110
# Ensure the id is between the minimum and maximum id
101
111
id = max (min_id , min (id , max_id ))
102
112
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
-
112
113
# Get the history for the current id
113
114
cursor .execute (
114
115
"SELECT `timestamp`, oldfileset, log FROM history WHERE fileset = %s ORDER BY `timestamp`" ,
0 commit comments