mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 17:15:31 +00:00
fix preload clear
This commit is contained in:
parent
6119510a23
commit
380fd6476b
2 changed files with 12 additions and 4 deletions
|
|
@ -40,7 +40,7 @@ async fn main() -> Result<()> {
|
||||||
} // librqbit impl dependency
|
} // librqbit impl dependency
|
||||||
let database = Database::init(&config.database)?;
|
let database = Database::init(&config.database)?;
|
||||||
let peers = Peers::init(&config.initial_peer)?;
|
let peers = Peers::init(&config.initial_peer)?;
|
||||||
let mut preload = Preload::init(
|
let preload = Preload::init(
|
||||||
config.preload,
|
config.preload,
|
||||||
config.preload_max_filecount,
|
config.preload_max_filecount,
|
||||||
config.preload_max_filesize,
|
config.preload_max_filesize,
|
||||||
|
|
@ -261,7 +261,7 @@ async fn main() -> Result<()> {
|
||||||
.delete(librqbit::api::TorrentIdOrHash::Id(id), false)
|
.delete(librqbit::api::TorrentIdOrHash::Id(id), false)
|
||||||
.await?;
|
.await?;
|
||||||
// cleanup tmp
|
// cleanup tmp
|
||||||
preload.clear();
|
preload.clear()?;
|
||||||
if config.debug {
|
if config.debug {
|
||||||
println!("\t\t\tadd `{i}` to index.")
|
println!("\t\t\tadd `{i}` to index.")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,16 @@ impl Preload {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear(&mut self) {
|
pub fn clear(&self) -> Result<()> {
|
||||||
self.directory.clear()
|
for entry in fs::read_dir(&self.directory)? {
|
||||||
|
let e = entry?;
|
||||||
|
if e.file_type()?.is_dir() {
|
||||||
|
fs::remove_dir_all(e)?;
|
||||||
|
} else {
|
||||||
|
fs::remove_file(e)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn directory(&self) -> &PathBuf {
|
pub fn directory(&self) -> &PathBuf {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue