mirror of
https://github.com/YGGverse/btracker.git
synced 2026-04-01 01:25:33 +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 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(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue