mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
add debug events
This commit is contained in:
parent
a70e9bc537
commit
07a87421dd
1 changed files with 13 additions and 4 deletions
|
|
@ -39,13 +39,16 @@ impl Preload {
|
||||||
persist_files: Option<HashSet<PathBuf>>,
|
persist_files: Option<HashSet<PathBuf>>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// persist torrent bytes to file
|
// persist torrent bytes to file
|
||||||
fs::write(self.torrent(info_hash)?, torrent_bytes)?;
|
let t = self.torrent(info_hash)?;
|
||||||
|
fs::write(&t, torrent_bytes)?;
|
||||||
|
log::debug!("persist torrent bytes for `{}`", t.to_string_lossy());
|
||||||
// persist preload files
|
// persist preload files
|
||||||
let mut d = PathBuf::from(&self.root);
|
let mut d = PathBuf::from(&self.root);
|
||||||
d.push(info_hash);
|
d.push(info_hash);
|
||||||
if d.exists() {
|
if d.exists() {
|
||||||
// clean previous data
|
// clean previous data
|
||||||
fs::remove_dir_all(&d)?
|
fs::remove_dir_all(&d)?;
|
||||||
|
log::debug!("clean preload content `{}`", d.to_string_lossy())
|
||||||
}
|
}
|
||||||
if let Some(f) = persist_files {
|
if let Some(f) = persist_files {
|
||||||
let r = d.components().count(); // count root offset once
|
let r = d.components().count(); // count root offset once
|
||||||
|
|
@ -69,13 +72,19 @@ impl Preload {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
fs::create_dir_all(n.parent().unwrap())?;
|
fs::create_dir_all(n.parent().unwrap())?;
|
||||||
fs::rename(o, n)?
|
fs::rename(&o, &n)?;
|
||||||
|
log::debug!(
|
||||||
|
"persist tmp file `{}` to `{}`",
|
||||||
|
o.to_string_lossy(),
|
||||||
|
n.to_string_lossy()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cleanup temporary files
|
// cleanup temporary files
|
||||||
let t = self.tmp(info_hash, false)?;
|
let t = self.tmp(info_hash, false)?;
|
||||||
if t.exists() {
|
if t.exists() {
|
||||||
fs::remove_dir_all(t)?
|
fs::remove_dir_all(&t)?;
|
||||||
|
log::debug!("clean tmp data `{}`", t.to_string_lossy())
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue