Skip to content

Commit

Permalink
System Tool & Scraper database corruption detection
Browse files Browse the repository at this point in the history
If "disp" field contains "##" we know that the database has been generated by MainUI instead of the script.
  • Loading branch information
cizia64 committed Jul 6, 2024
1 parent 972e6a6 commit d5aeb4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Apps/Scraper/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ previous_crc_DB=$(cat "$crc_DB_file")
echo "Current show.json CRC32: $current_crc_Emus | Current Menu_cache7.db CRC32: $current_crc_DB"
echo "Previous show.json CRC32: $previous_crc_Emus | Previous Menu_cache7.db CRC32: $previous_crc_DB"



sync
contains_hashes=$(sqlite3 "$database_file" "SELECT COUNT(*) FROM Menu_roms WHERE disp LIKE '%##%';")
# If any 'disp' field contains '##', delete the database
if [ "$contains_hashes" -gt 0 ]; then
rm -f "$database_file"
echo "Corrupted Ssraper database, re-building..."
fi

# If CRC32 have changed, perform operations and update CRC file
if [ "$current_crc_Emus" != "$previous_crc_Emus" ] || [ "$current_crc_DB" != "$previous_crc_DB" ]; then
Expand Down
13 changes: 12 additions & 1 deletion Apps/SystemTools/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mkdir -p /mnt/SDCARD/System/etc
if [ ! -f "/mnt/SDCARD/System/etc/crossmix.json" ]; then
touch "/mnt/SDCARD/System/etc/crossmix.json"
fi
sync

####################################### For testing :
# rm "$database_file"
Expand All @@ -32,7 +33,17 @@ if [ "$rebuildmenu" = true ]; then
sync
LaunchMessage="Building Menu..."
else
LaunchMessage="Loading..."
LaunchMessage="Loading..."

contains_hashes=$(sqlite3 "$database_file" "SELECT COUNT(*) FROM Menu_roms WHERE disp LIKE '%##%';")
# If any 'disp' field contains '##', delete the database
if [ "$contains_hashes" -gt 0 ]; then
rm -f "$database_file"
echo "Corrupted System Tools database, re-building..."
LaunchMessage="Re-Building Menu..."
fi


fi

/mnt/SDCARD/System/usr/trimui/scripts/infoscreen.sh -m "$LaunchMessage"
Expand Down

0 comments on commit d5aeb4d

Please sign in to comment.