@@ -154,7 +154,7 @@ def fileset():
154
154
"""
155
155
if old_id is not None :
156
156
html += f"""<h3><u>Redirected from Fileset: { old_id } </u></h3>"""
157
- html += f"<button type='button' onclick=\" location.href='/fileset/{ id } /merge'\" >Manual Merge </button>"
157
+ html += f"<button type='button' onclick=\" location.href='/fileset/{ id } /merge'\" >Compare Filesets </button>"
158
158
html += f"""
159
159
<form action="/fileset/{ id } /mark_full" method="post" style="display:inline;">
160
160
<button type='submit'>Mark as full</button>
@@ -836,111 +836,8 @@ def update_fileset(id):
836
836
837
837
@app .route ("/fileset/<int:id>/merge" , methods = ["GET" , "POST" ])
838
838
def merge_fileset (id ):
839
- if request .method == "POST" :
840
- search_query = request .form ["search" ]
841
-
842
- connection = db_connect ()
843
-
844
- try :
845
- with connection .cursor () as cursor :
846
- query = f"""
847
- SELECT
848
- fs.*,
849
- g.name AS game_name,
850
- g.engine AS game_engine,
851
- g.platform AS game_platform,
852
- g.language AS game_language,
853
- g.extra AS extra
854
- FROM
855
- fileset fs
856
- LEFT JOIN
857
- game g ON fs.game = g.id
858
- WHERE g.name LIKE '%{ search_query } %' OR g.platform LIKE '%{ search_query } %' OR g.language LIKE '%{ search_query } %'
859
- """
860
- cursor .execute (query )
861
- results = cursor .fetchall ()
862
-
863
- html = f"""
864
- <!DOCTYPE html>
865
- <html>
866
- <head>
867
- <link rel="stylesheet" type="text/css" href="{{{{ url_for('static', filename='style.css') }}}}">
868
- <link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
869
- <link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
870
- </head>
871
- <body>
872
- <nav>
873
- <div class="logo">
874
- <a href="{{{{ url_for('home') }}}}">
875
- <img src="{{{{ url_for('static', filename='integrity_service_logo_256.png') }}}}" alt="Logo">
876
- </a>
877
- </div>
878
- <div class="nav-buttons">
879
- <a href="{{{{ url_for('user_games_list') }}}}">User Games List</a>
880
- <a href="{{{{ url_for('ready_for_review') }}}}">Ready for review</a>
881
- <a href="{{{{ url_for('fileset_search') }}}}">Fileset Search</a>
882
- <a href="{{{{ url_for('logs') }}}}">Logs</a>
883
- <a href="{{{{ url_for('config') }}}}">Config</a>
884
- </div>
885
- </nav>
886
- <h2 style="margin-top: 80px;">Search Results for '{ search_query } '</h2>
887
- <form method="POST">
888
- <input type="text" name="search" placeholder="Search fileset">
889
- <input type="submit" value="Search">
890
- </form>
891
- <table>
892
- <tr><th>ID</th><th>Game Name</th><th>Platform</th><th>Language</th><th>Extra</th><th>Action</th></tr>
893
- """
894
- for result in results :
895
- html += f"""
896
- <tr>
897
- <td>{ result ["id" ]} </td>
898
- <td>{ result ["game_name" ]} </td>
899
- <td>{ result ["game_platform" ]} </td>
900
- <td>{ result ["game_language" ]} </td>
901
- <td>{ result ["extra" ]} </td>
902
- <td><a href="/fileset/{ id } /merge/confirm?target_id={ result ["id" ]} ">Select</a></td>
903
- </tr>
904
- """
905
- html += "</table>\n "
906
- html += "</body>\n </html>"
907
-
908
- return render_template_string (html )
909
-
910
- finally :
911
- connection .close ()
912
-
913
- return """
914
- <!DOCTYPE html>
915
- <html>
916
- <head>
917
- <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
918
- <link rel="icon" type="image/png" sizes="32x32" href="/static/favicon-32x32.png">
919
- <link rel="icon" type="image/png" sizes="16x16" href="/static/favicon-16x16.png">
920
- </head>
921
- <body>
922
- <nav>
923
- <div class="logo">
924
- <a href="{{ url_for('home') }}">
925
- <img src="{{ url_for('static', filename='integrity_service_logo_256.png') }}" alt="Logo">
926
- </a>
927
- </div>
928
- <div class="nav-buttons">
929
- <a href="{{ url_for('user_games_list') }}">User Games List</a>
930
- <a href="{{ url_for('ready_for_review') }}">Ready for review</a>
931
- <a href="{{ url_for('fileset_search') }}">Fileset Search</a>
932
- <a href="{{ url_for('logs') }}">Logs</a>
933
- <a href="{{ url_for('config') }}">Config</a>
934
- </div>
935
- </nav>
936
- <h2 style="margin-top: 80px;">Search Fileset to Merge</h2>
937
- <form method="POST">
938
- <input type="text" name="search" placeholder="Search fileset">
939
- <input type="submit" value="Search">
940
- </form>
941
- </body>
942
- </html>
943
- """
839
+ url = f"/fileset_search?source_id={ id } "
840
+ return redirect (url )
944
841
945
842
946
843
@app .route ("/fileset/<int:id>/possible_merge" , methods = ["GET" , "POST" ])
@@ -1296,7 +1193,7 @@ def highlight_differences(source, target):
1296
1193
# For matched_files, files is a tuple of filename from source file and target file
1297
1194
# For unmatched_files, files is the filename of the files that was not common.
1298
1195
for files in file_category :
1299
- if is_common_file :
1196
+ if is_common_file and len ( matched_files ) != 0 :
1300
1197
(target_filename , source_filename ) = files
1301
1198
1302
1199
# Also remove common files from source and target filenames set
@@ -1325,7 +1222,11 @@ def highlight_differences(source, target):
1325
1222
1326
1223
keys = sorted (set (source_dict .keys ()) | set (target_dict .keys ()))
1327
1224
1328
- tr_class = "matched" if is_common_file else "unmatched"
1225
+ tr_class = (
1226
+ "matched"
1227
+ if (is_common_file and len (matched_files ) != 0 )
1228
+ else "unmatched"
1229
+ )
1329
1230
html += f"""<tr class="{ tr_class } ">
1330
1231
<td colspan='3'>
1331
1232
<strong>{ source_filename } </strong> { " - mac_file" if is_mac_file else "" }
@@ -1369,9 +1270,14 @@ def highlight_differences(source, target):
1369
1270
and source_filename .lower () in detection_files_set
1370
1271
):
1371
1272
is_detection = "1"
1372
- fname = source_to_target_matched_map [
1273
+ fname = (
1373
1274
source_filename .lower ()
1374
- ]
1275
+ if source_filename .lower ()
1276
+ not in source_to_target_matched_map
1277
+ else source_to_target_matched_map [
1278
+ source_filename .lower ()
1279
+ ]
1280
+ )
1375
1281
detection_type = target_files_map [fname ].get (
1376
1282
"detection_type" , ""
1377
1283
)
0 commit comments