Fix handling of paths longer than 260 chars on Windows during export (#847)

This commit is contained in:
Jackson Kruger 2023-10-30 20:27:30 -05:00 committed by GitHub
parent bd18dbdbe8
commit f5c7f90d19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,9 @@ pub enum ErrorKind {
#[error("I/O error: {0}")]
IOError(#[from] util::io::IOError),
#[error("I/O (std) error: {0}")]
StdIOError(#[from] std::io::Error),
#[error("Error launching Minecraft: {0}")]
LauncherError(String),

View File

@ -142,10 +142,13 @@ pub struct ProjectPathId(pub PathBuf);
impl ProjectPathId {
// Create a new ProjectPathId from a full file path
pub async fn from_fs_path(path: &PathBuf) -> crate::Result<Self> {
let profiles_dir: PathBuf = io::canonicalize(
// This is avoiding dunce::canonicalize deliberately. On Windows, paths will always be convert to UNC,
// but this is ok because we are stripping that with the prefix. Using std::fs avoids different behaviors with dunce that
// come with too-long paths
let profiles_dir: PathBuf = std::fs::canonicalize(
State::get().await?.directories.profiles_dir().await,
)?;
let path: PathBuf = io::canonicalize(path)?;
let path: PathBuf = std::fs::canonicalize(path)?;
let path = path
.strip_prefix(profiles_dir)
.ok()