BUGBUG: Fixed config not saving (i forgor)
This commit is contained in:
		
							parent
							
								
									3ba685448a
								
							
						
					
					
						commit
						057816bd65
					
				
							
								
								
									
										13
									
								
								config.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								config.json
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,13 @@
 | 
			
		|||
{
 | 
			
		||||
  "ytdlp": {
 | 
			
		||||
    "path": "/usr/bin/yt-dlp",
 | 
			
		||||
    "is_python": false
 | 
			
		||||
  },
 | 
			
		||||
  "spotdl": {
 | 
			
		||||
    "path": "/home/mcorange/.local/bin/spotdl",
 | 
			
		||||
    "is_python": false
 | 
			
		||||
  },
 | 
			
		||||
  "python": {
 | 
			
		||||
    "path": ""
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -58,6 +58,7 @@ impl ConfigWrapper {
 | 
			
		|||
impl Config {
 | 
			
		||||
    pub async fn parse(cli: &CliArgs) -> Result<Self> {
 | 
			
		||||
        if !cli.config.exists() {
 | 
			
		||||
            log::info!("Config doesnt exist");
 | 
			
		||||
            return Self::setup_config(&cli).await;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -127,6 +128,14 @@ impl Config {
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        s.save(cli.config.clone().into_std_path_buf())?;
 | 
			
		||||
        Ok(s)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn save(&self, path: PathBuf) -> anyhow::Result<()> {
 | 
			
		||||
        let data = serde_json::to_string_pretty(self)?;
 | 
			
		||||
        std::fs::write(path, data)?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user