mirror of
https://github.com/SabreTools/MPF.git
synced 2026-02-03 21:29:27 +00:00
[Request] Remove drive letters from !protectionInfo.txt #488
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JohnVeness on GitHub (Jan 16, 2023).
Originally assigned to: @mnadareski on GitHub.
Is your feature request related to a problem? Please describe.
I usually dump with two different drives and like to diff the !submissionInfo.txt and !protectionInfo.txt files afterwards to check they dumped the same. The !submissionInfo.txt files will differ a little at the end because of the different disc drive models, but that's fine and manageable.
However, what is annoying is that every line in !protectionInfo.txt will differ between the two dumps because the drive letter will be different.
Describe the solution you'd like
Please can you remove (or normalise) the drive letter from !protectionInfo.txt? E.g. a file like:
could change to:
or to (where it always uses x whatever the actual drive letter is):
@mnadareski commented on GitHub (Jan 16, 2023):
The protection info file is just there to provide more complete information than what is included in the submission info. It is intentionally full-pathed as a result.
@Deterous commented on GitHub (Oct 12, 2023):
Removing the drive letter is not something I would personally want MPF to do.
If it helps, there are a few ways for you to automate this:
Regex: replace
^..with(nothing). E.g. in notepad++, replace^..(.*)with$1Python: https://gist.github.com/Deterous/2e15bd7caa11eb115290594d491e2282
@JohnVeness commented on GitHub (Oct 12, 2023):
Thanks for the script @Deterous :)
I've noticed that, for some reason, the order of the lines in !protectionInfo.txt is not consistent from one dump to another, so diffing them is annoying even if the drive letter is omitted! I guess I could run the file through
sort.Overall, although in an ideal world I'd prefer !protectionInfo.txt to be identical between two different dumps of the same disc, if it's not easy or desirable for MPF to achieve this, I don't mind this being closed.
@mnadareski commented on GitHub (Oct 18, 2023):
This doesn't apply to Linux paths, so approaching this in a reasonable way is a bit difficult from within the code.
@Deterous commented on GitHub (Jan 6, 2024):
@JohnVeness I gave this change a go with this commit:
6f8f43d4f0If you can help test it (MPF UI vs MPF.Check, Windows vs Mac vs Linux, Different discs), the builds with the change are here: https://ci.appveyor.com/project/Deterous/mpf/builds/48894181/artifacts
@JohnVeness commented on GitHub (Jan 6, 2024):
@Deterous Many thanks. I've done some testing, MPF UI in Windows, MPF.Check in Windows, MPF.Check in Linux (all on the same PC and drive, dual-booting), with two discs I had to hand, The Movies and Rome: Total War: Gold Edition.
For The Movies:
MPF UI in Windows:
MPF.Check in Windows:
MPF.Check in Linux:
For Rome: Total War: Gold Edition:
MPF UI in Windows:
MPF.Check in Windows:
MPF.Check in Linux:
You see that the outputs for MPF UI and MPF.Check in Windows have successfully had the drive letter removed. The lines come out in a different order, though, which is a problem I've noticed before, which makes "diff" annoying! Maybe the lines can be sorted alphabetically before output?
The output for MPF.Check in Linux is of the same form as version 3.0.3, namely that it doesn't have a drive letter and so doesn't have a drive letter that can be removed! Given that the command-line for MPF.Check includes "-p /run/media/john/MOVIES" or "-p /run/media/john/ROMETWGOLD" you could maybe use that to remove that text from the beginning of each line? Although watch out for people typing "-p /run/media/john/MOVIES/" or "-p /run/media/john/ROMETWGOLD/", i.e. including the end slash, especially as autocomplete on the command-line will include the last slash by default.
The Linux output is also in a different line order. And of course it uses forward-slashes instead of back-slashes in Windows so a diff between the two would show every line as changed. You might want to consider changing the Linux output to match the Windows, or vice versa.
I don't have a Mac to hand, but that would also use forward-slash directory separators.
Hope this helps!
@Deterous commented on GitHub (Jan 6, 2024):
Perfect, that is the expected output. As mnadareski said above, this doesn't apply to Linux paths, so this change only benefits Windows users (Linux output is unchanged as desired). I see how removing the full Linux "drive path" would make it cleaner, but that would require larger code changes outside of this function. Another approach would be changing how BOS works, that's not in scope.
As for the order in which things are printed, MPF is printing them in dictionary order as it receives from BOS. The keys themselves can be ordered alphabetically before printing to file, as I have done here:
f9f854e70bYou can test it with this build: https://ci.appveyor.com/project/Deterous/mpf/builds/48895411/artifacts
Although I'll ask @mnadareski if this is a desirable change before making a PR. Alphabetical order might not be preferred, but instead by "folder". This could be done by BOS outputting a SortedDictionary instead.
@JohnVeness commented on GitHub (Jan 8, 2024):
@Deterous Thanks, sorting seems to work with that version, so the output from MPF UI and MPF.Check on Windows are the same. This will make comparisons between different dumps on that platform much easier, which was my original issue :)
Output is also sorted on the Linux version too, although obviously differs from the Windows output as expected.
I notice one more thing (tell me if I should open this as a new issue), which you can see in the outputs in https://github.com/SabreTools/MPF/issues/448#issuecomment-1879789151 - for some reason I notice that the Linux version of MPF.Check, when outputting the line for the root folder of the disc, shows more details than the Windows versions of MPF UI and MPF.Check. E.g. Linux will output "/run/media/john/ROMETWGOLD/: Macrovision Security Driver 4.00.060 / SafeDisc 4.00.000-4.70.000, SafeDisc 1.06.000+, SafeDisc 3+ (DVD), SafeDisc 4.00.002+" compared to Windows ": SafeDisc 3+ (DVD)". It looks like the Linux version is showing all the protections found in all the files below root, and the Windows version only one. Any ideas?
@Deterous commented on GitHub (Jan 8, 2024):
That could potentially be due to how BOS treats Windows vs Linux paths as files vs directories. Please open an issue with BOS, I may test that out another day. For now, I will try get these changes merged and close this particular issue.
@JohnVeness commented on GitHub (Jan 8, 2024):
Thanks for all your help :)
@Deterous commented on GitHub (Jan 9, 2024):
Removing drive letters will not be done by default, but it will be an option within both MPF and MPF.Check
The alphabetical sorting will be done by default, though