mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
fix clear impl
This commit is contained in:
parent
25a71b0134
commit
03581c2192
1 changed files with 6 additions and 6 deletions
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::{Result, bail};
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
/// Temporary file storage for `librqbit` preload data
|
||||
pub struct Preload {
|
||||
|
|
@ -25,12 +25,12 @@ impl Preload {
|
|||
}
|
||||
|
||||
pub fn clear(&self) -> Result<()> {
|
||||
for entry in fs::read_dir(&self.directory)? {
|
||||
let e = entry?;
|
||||
if e.file_type()?.is_dir() {
|
||||
fs::remove_dir_all(e)?;
|
||||
for e in fs::read_dir(&self.directory)? {
|
||||
let p = e?.path();
|
||||
if p.is_dir() {
|
||||
fs::remove_dir_all(p)?;
|
||||
} else {
|
||||
fs::remove_file(e)?;
|
||||
fs::remove_file(p)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue