mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
skip directory create if already exists, return PathBuf, convert to string outside
This commit is contained in:
parent
9a64995bf5
commit
b4d379c650
2 changed files with 9 additions and 4 deletions
|
|
@ -128,7 +128,9 @@ async fn main() -> Result<()> {
|
||||||
config.preload_max_filecount.unwrap_or_default(),
|
config.preload_max_filecount.unwrap_or_default(),
|
||||||
)),
|
)),
|
||||||
// the folder to preload temporary files (e.g. images for the audio albums)
|
// the folder to preload temporary files (e.g. images for the audio albums)
|
||||||
output_folder: Some(preload.output_folder(&i)?),
|
output_folder: Some(
|
||||||
|
preload.output_folder(&i)?.to_string_lossy().to_string(),
|
||||||
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,14 @@ impl Preload {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn output_folder(&self, info_hash: &str) -> Result<String> {
|
/// * create new directory if not exists
|
||||||
|
pub fn output_folder(&self, info_hash: &str) -> Result<PathBuf> {
|
||||||
let mut p = PathBuf::from(&self.directory);
|
let mut p = PathBuf::from(&self.directory);
|
||||||
p.push(info_hash);
|
p.push(info_hash);
|
||||||
fs::create_dir(&p)?;
|
if !p.exists() {
|
||||||
Ok(p.to_string_lossy().to_string())
|
fs::create_dir(&p)?
|
||||||
|
}
|
||||||
|
Ok(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn root(&self) -> PathBuf {
|
pub fn root(&self) -> PathBuf {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue