Preserve unicode game titles from ludusavi - #60
Conversation
When encoding is not specified explicitly as "utf-8", `subprocess.run` uses the default system encoding, which is typically CP1252 on Windows. This causes UTF-8 characters in game titles to be decoded incorrectly. After this fix, titles like "Grand Theft Auto: The Trilogy – The Definitive Edition" are correctly displayed as "Grand Theft Auto: The Trilogy – The Definitive Edition".
|
Sorry in advance for not adding a test for this; I'm just not competent |
Tudzer's fix was right and the diagnosis was exact: text=True decodes with the locale default, which is cp1252 on a stock Windows install, while Ludusavi emits UTF-8. Confirmed here - locale.getpreferredencoding() returns cp1252 on this machine. Five other calls had the same defect. One of them matters more than the original. run_rclone parses rclone's output into the remote version listing that prune and restore work from, and _slugify keeps non-ASCII rather than stripping it - 'Pokemon' with an accent slugs to an id that still has the accent, and that id is the remote path. A mangled listing there is not a cosmetic wrong title, it is retention and restore reading the wrong names. The rest are the Xbox package query, which shells out to PowerShell, and the three systemctl calls. The test is a whole-tree AST assertion rather than six separate ones, because the bug is "somebody added a subprocess call and forgot", and that is the thing worth catching. It also proves it can see a violation, since a guard that cannot fail is not a guard.
|
Correct, and the diagnosis was exact. Confirmed here: I have pushed the rest onto this branch rather than sending you back round again. Five other calls had the same defect:
So your one-line fix turned out to sit on top of a systemic one, and the systemic one reaches the code that deletes things. The test is a single AST assertion over the whole tree rather than six separate ones, because the bug is "somebody adds a subprocess call and forgets" and that is the shape worth catching. It also asserts it can detect a violation, since a guard that cannot fail is not a guard. Second one of these you have found now. The timestamp bug had been shipping since 0.6.0, and this one since the beginning — both in code I have read many times. |
|
thanks for contribution no proplem with the test i added it @Tudzer |
Two fixes, one found by a contributor and one found by using the thing. Game titles with non-ASCII characters were mangled: text=True decodes with the locale default, cp1252 on a stock Windows install, while Ludusavi and rclone emit UTF-8. Found by @Tudzer in #60, who fixed the Ludusavi call. Five others had the same defect, and rclone's mattered most - a game id keeps the non-ASCII from its title and an id is part of the remote path, so a mangled listing is retention and restore reading the wrong paths. Removing a game now sticks. `gsg remove --purge` deleted a game and its backups and the next scan added it straight back, because nothing recorded the removal and a launcher-owned game only stays skipped while its launcher reports it installed (#61). Co-authored-by: Vasanthdev2004 <Vasanthdev2004@users.noreply.github.com>
When encoding is not specified explicitly as "utf-8",
subprocess.runuses the default system encoding, which is typically CP1252 on Windows. This causes UTF-8 characters in game titles to be decoded incorrectly.After this fix, titles like "Grand Theft Auto: The Trilogy – The Definitive Edition" are correctly displayed as "Grand Theft Auto: The Trilogy – The Definitive Edition".