mirror of
				https://github.com/WarrenHood/MCModpackManager.git
				synced 2025-11-04 01:58:41 +00:00 
			
		
		
		
	Canonicalise paths passed in to profile commands
This commit is contained in:
		
							parent
							
								
									7afa514783
								
							
						
					
					
						commit
						5b5dc0f4df
					
				| 
						 | 
				
			
			@ -484,7 +484,7 @@ async fn main() -> anyhow::Result<()> {
 | 
			
		|||
                            instance_directory,
 | 
			
		||||
                        } => {
 | 
			
		||||
                            let mut userdata = profiles::Data::load()?;
 | 
			
		||||
                            let profile = Profile::new(&instance_directory, pack_source, side);
 | 
			
		||||
                            let profile = Profile::new(&instance_directory, pack_source, side)?;
 | 
			
		||||
                            userdata.add_profile(&name, profile);
 | 
			
		||||
                            userdata.save()?;
 | 
			
		||||
                            println!("Saved profile '{name}'");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,8 +26,11 @@ impl FromStr for PackSource {
 | 
			
		|||
            let url = s.trim_start_matches("git+").to_string();
 | 
			
		||||
            Ok(PackSource::Git { url })
 | 
			
		||||
        } else {
 | 
			
		||||
            let path = PathBuf::from(s);
 | 
			
		||||
            Ok(PackSource::Local { path })
 | 
			
		||||
            let path = PathBuf::from(s).canonicalize();
 | 
			
		||||
            match path {
 | 
			
		||||
                Ok(path) => Ok(PackSource::Local { path }),
 | 
			
		||||
                Err(e) => Err(e.to_string())
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -49,12 +52,16 @@ pub struct Profile {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
impl Profile {
 | 
			
		||||
    pub fn new(instance_folder: &Path, pack_source: PackSource, side: DownloadSide) -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            instance_folder: instance_folder.into(),
 | 
			
		||||
    pub fn new(
 | 
			
		||||
        instance_folder: &Path,
 | 
			
		||||
        pack_source: PackSource,
 | 
			
		||||
        side: DownloadSide,
 | 
			
		||||
    ) -> Result<Self> {
 | 
			
		||||
        Ok(Self {
 | 
			
		||||
            instance_folder: instance_folder.canonicalize()?,
 | 
			
		||||
            pack_source,
 | 
			
		||||
            side,
 | 
			
		||||
        }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn install(&self) -> Result<()> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,7 +84,8 @@ impl TryFrom<ProfileSettings> for profiles::Profile {
 | 
			
		|||
            &instance_dir,
 | 
			
		||||
            profiles::PackSource::from_str(&pack_source)?,
 | 
			
		||||
            value.side,
 | 
			
		||||
        ))
 | 
			
		||||
        )
 | 
			
		||||
        .map_err(|e| e.to_string())?)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue