Fix handling of paths longer than 260 chars on Windows during export #847
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.
This addresses an issue brought to our attention by the modpack "Mimi Adventure", with the following repro steps, using version 0.6.0 of the app on Windows:
This produces the following error:
This error occurs because the path length is over 260 characters (Windows docs), which caused
dunce::canonicalize
(lib.rs line 187) to default tostd::fs::canonicalize
, which canonicalizes to a UNC path. This path begins with "\\?\", so when we try to strip the profile prefix (which isn't UNC) from the file's path, it fails.My (somewhat clunky) solution is to use
std::fs::canonicalize
for both the profile path and the one we're canonicalizing, which should behave consistently regardless of length. The UNC path weirdness shouldn't matter to us here as we're only doing this if we can subtract the canonicalized profile path from the input path, canceling out the UNC prefix.