-
Notifications
You must be signed in to change notification settings - Fork 29
Add AuroraDriveFixerSmart and DeadEntryCleaner utility scripts #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EduDicaseGameplay
wants to merge
5
commits into
XboxUnity:master
Choose a base branch
from
EduDicaseGameplay:add-new-utility-scripts
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d87c8a2
Add AuroraDriveFixerSmart and DeadEntryCleaner utility scripts
EduDicaseGameplay 86c4da2
Translate script descriptions to English
EduDicaseGameplay 4bf26a4
Translate descriptions, comments, and script results into English
EduDicaseGameplay ed6d202
Improve Title Update uniqueness check by considering all relevant ide…
EduDicaseGameplay f982a81
Improve dead entry detection, Homebrew TitleID handling and storage l…
EduDicaseGameplay File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,250 @@ | ||
| scriptTitle = "Aurora Drive Fixer Smart" | ||
| scriptAuthor = "Eduardo Henrique/Canal Edu Dicas e Gameplay" | ||
| scriptVersion = 1.0 | ||
| scriptDescription = "Fixes scanpaths and Title Updates after drive cloning, with intelligent and safe handling of duplicates." | ||
| scriptIcon = "icon.png" | ||
| scriptPermissions = { "filesystem", "sql" } | ||
|
|
||
| ExitTriggered = false | ||
|
|
||
| -------------------------------------------------- | ||
| -- SELECT DRIVE (SERIAL) | ||
| -------------------------------------------------- | ||
| function selectDrive() | ||
|
|
||
| local drives = {} | ||
| local dialog = {} | ||
|
|
||
| for i, d in ipairs(FileSystem.GetDrives(false)) do | ||
| drives[i] = { | ||
| mount = d["MountPoint"], | ||
| serial = d["Serial"] | ||
| } | ||
|
|
||
| dialog[i] = | ||
| d["MountPoint"] .. | ||
| " (Serial: " .. string.sub(d["Serial"], 1, 12) .. "...)" | ||
| end | ||
|
|
||
| local result = Script.ShowPopupList( | ||
| "Select the drive where the games are located:", | ||
| "No device found.", | ||
| dialog | ||
| ) | ||
|
|
||
| if result.Canceled then | ||
| ExitTriggered = true | ||
| return nil | ||
| end | ||
|
|
||
| return drives[result.Selected.Key] | ||
| end | ||
|
|
||
| -------------------------------------------------- | ||
| -- ASK WHETHER TO SKIP SCANPATHS | ||
| -------------------------------------------------- | ||
| function askSkipScanpaths() | ||
|
|
||
| local confirm = Script.ShowMessageBox( | ||
| "Scanpaths", | ||
| "Do you also want to fix Scanpaths?\n\n(If not, only Title Updates will be fixed)", | ||
| "Yes", | ||
| "Only TUs" | ||
| ) | ||
|
|
||
| return confirm.Button ~= 1 | ||
| end | ||
|
|
||
| -------------------------------------------------- | ||
| -- SCANPATHS | ||
| -------------------------------------------------- | ||
| function fixScanpaths(newSerial) | ||
|
|
||
| local rows = {} | ||
| local dialog = "" | ||
|
|
||
| for _, row in pairs(Sql.ExecuteFetchRows("SELECT id, path, deviceid FROM scanpaths ORDER BY id ASC") or {}) do | ||
| if row["DeviceId"] ~= newSerial then | ||
| table.insert(rows, row) | ||
|
|
||
| dialog = dialog .. | ||
| row["Path"] .. | ||
| " (" .. | ||
| string.sub(row["DeviceId"],1,6) .. | ||
| " → " .. | ||
| string.sub(newSerial,1,6) .. | ||
| ")\n" | ||
| end | ||
| end | ||
|
|
||
| if #rows == 0 then | ||
| Script.ShowMessageBox("Scanpaths", "No scanpath needs to be changed.", "OK") | ||
| return 0, 0 | ||
| end | ||
|
|
||
| local confirm = Script.ShowMessageBox( | ||
| "Scanpaths found", | ||
| dialog, | ||
| "Fix", | ||
| "Cancel" | ||
| ) | ||
|
|
||
| if confirm.Button ~= 1 then return 0, 0 end | ||
|
|
||
| local success = 0 | ||
| local failed = 0 | ||
|
|
||
| for _, row in pairs(rows) do | ||
| local ok = pcall(function() | ||
| Sql.Execute("UPDATE scanpaths SET deviceid='"..newSerial.."' WHERE id="..row["Id"]) | ||
| end) | ||
|
|
||
| if ok then success = success + 1 else failed = failed + 1 end | ||
| end | ||
|
|
||
| return success, failed | ||
| end | ||
|
|
||
| -------------------------------------------------- | ||
| -- TITLE UPDATES (SMART + VERSION) | ||
| -------------------------------------------------- | ||
| function fixTitleUpdates(newSerial) | ||
|
|
||
| local rows = {} | ||
| local dialog = "" | ||
|
|
||
| for _, row in pairs(Sql.ExecuteFetchRows( | ||
| "SELECT id, titleid, mediaid, baseversion, version, hash, filename, displayname, livedeviceid " .. | ||
| "FROM titleupdates ORDER BY displayname ASC" | ||
| ) or {}) do | ||
| if row["LiveDeviceId"] ~= newSerial then | ||
| table.insert(rows, row) | ||
|
|
||
| dialog = dialog .. | ||
| row["DisplayName"] .. | ||
| " (v"..tostring(row["Version"])..") (" .. | ||
| string.sub(row["LiveDeviceId"],1,6) .. | ||
| " → " .. | ||
| string.sub(newSerial,1,6) .. | ||
| ")\n" | ||
| end | ||
| end | ||
|
|
||
| if #rows == 0 then | ||
| Script.ShowMessageBox("Title Updates", "No Title Update needs to be changed.", "OK") | ||
| return 0, 0, 0 | ||
| end | ||
|
|
||
| local confirm = Script.ShowMessageBox( | ||
| "Title Updates found", | ||
| dialog, | ||
| "Fix", | ||
| "Skip" | ||
| ) | ||
|
|
||
| if confirm.Button ~= 1 then return 0, 0, 0 end | ||
|
|
||
| local success = 0 | ||
| local failed = 0 | ||
| local removed = 0 | ||
|
|
||
| for _, row in pairs(rows) do | ||
|
|
||
| local exists = Sql.ExecuteFetchRows( | ||
| "SELECT id FROM titleupdates " .. | ||
| "WHERE filename='" .. row["FileName"] .. | ||
| "' AND titleid='" .. row["TitleId"] .. | ||
| "' AND mediaid='" .. row["MediaId"] .. | ||
| "' AND baseversion='" .. row["BaseVersion"] .. | ||
| "' AND version='" .. row["Version"] .. | ||
| "' AND hash='" .. row["Hash"] .. | ||
| "' AND livedeviceid='" .. newSerial .. | ||
| "' AND id<>" .. row["Id"] | ||
| ) | ||
|
|
||
| if exists and #exists > 0 then | ||
| -- Remove true duplicate already existing on the target device. | ||
| local ok = pcall(function() | ||
| Sql.Execute("DELETE FROM titleupdates WHERE id="..row["Id"]) | ||
| end) | ||
|
|
||
| if ok then removed = removed + 1 else failed = failed + 1 end | ||
|
|
||
| else | ||
| -- update normally | ||
| local ok = pcall(function() | ||
| Sql.Execute("UPDATE titleupdates SET livedeviceid='"..newSerial.."' WHERE id="..row["Id"]) | ||
| end) | ||
|
|
||
| if ok then success = success + 1 else failed = failed + 1 end | ||
| end | ||
| end | ||
|
|
||
| return success, failed, removed | ||
| end | ||
|
|
||
| -------------------------------------------------- | ||
| -- MAIN | ||
| -------------------------------------------------- | ||
| function main() | ||
|
|
||
| -------------------------------------------------- | ||
| -- BACKUP WARNING | ||
| -------------------------------------------------- | ||
| local backupWarning = Script.ShowMessageBox( | ||
| "Important Warning", | ||
| "Before continuing, it is highly recommended to back up the Aurora database.\n\n" .. | ||
| "Default location:\n" .. | ||
| "Data\\Databases\\content.db\n" .. | ||
| "or\n" .. | ||
| "User\\Data\\Databases\\content.db\n\n" .. | ||
| "Do you want to continue anyway?", | ||
| "Continue", | ||
| "Cancel" | ||
| ) | ||
|
|
||
| if backupWarning.Button ~= 1 then return end | ||
|
|
||
| local drive = selectDrive() | ||
| if not drive then return end | ||
|
|
||
| local confirm = Script.ShowMessageBox( | ||
| "Confirm", | ||
| "Device:\n\n" .. | ||
| drive.mount .. | ||
| "\nSerial: " .. string.sub(drive.serial,1,16) .. | ||
| "\n\nContinue?", | ||
| "Yes", | ||
| "Cancel" | ||
| ) | ||
|
|
||
| if confirm.Button ~= 1 then return end | ||
|
|
||
| local skipScan = askSkipScanpaths() | ||
|
|
||
| local scanOK, scanFail = 0, 0 | ||
| if not skipScan then | ||
| scanOK, scanFail = fixScanpaths(drive.serial) | ||
| end | ||
|
|
||
| local tuOK, tuFail, tuRemoved = fixTitleUpdates(drive.serial) | ||
|
|
||
| local msg = | ||
| "Scanpaths fixed: "..scanOK.. | ||
| "\nScanpath failures: "..scanFail.. | ||
| "\n\nTUs fixed: "..tuOK.. | ||
| "\nTUs removed (true duplicates): "..tuRemoved.. | ||
| "\nTU failures: "..tuFail.. | ||
| "\n\nRestart Aurora to apply the changes." | ||
|
|
||
| local confirm = Script.ShowMessageBox( | ||
| "Completed", | ||
| msg, | ||
| "Restart", | ||
| "Later" | ||
| ) | ||
|
|
||
| if confirm.Button == 1 then | ||
| Aurora.Restart() | ||
| end | ||
| end | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.