fix clear impl

This commit is contained in:
yggverse 2025-08-02 11:45:06 +03:00
parent 25a71b0134
commit 03581c2192

View file

@ -1,5 +1,5 @@
use anyhow::{Result, bail}; use anyhow::{Result, bail};
use std::path::PathBuf; use std::{fs, path::PathBuf};
/// Temporary file storage for `librqbit` preload data /// Temporary file storage for `librqbit` preload data
pub struct Preload { pub struct Preload {
@ -25,12 +25,12 @@ impl Preload {
} }
pub fn clear(&self) -> Result<()> { pub fn clear(&self) -> Result<()> {
for entry in fs::read_dir(&self.directory)? { for e in fs::read_dir(&self.directory)? {
let e = entry?; let p = e?.path();
if e.file_type()?.is_dir() { if p.is_dir() {
fs::remove_dir_all(e)?; fs::remove_dir_all(p)?;
} else { } else {
fs::remove_file(e)?; fs::remove_file(p)?;
} }
} }
Ok(()) Ok(())