Skip to content

Commit

Permalink
Fix handling of paths longer than 260 chars on Windows during export (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
OmegaJak authored Oct 31, 2023
1 parent bd18dbd commit f5c7f90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions theseus/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
7 changes: 5 additions & 2 deletions theseus/src/state/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f5c7f90

Please sign in to comment.