mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
fix output file path resolver
This commit is contained in:
parent
2f0f55d359
commit
eea10011ed
1 changed files with 12 additions and 6 deletions
|
|
@ -46,13 +46,20 @@ impl Preload {
|
||||||
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())
|
log::debug!("clean previous data `{}`", d.to_string_lossy())
|
||||||
}
|
}
|
||||||
|
// init temporary path without creating the dir (delegate to `librqbit`)
|
||||||
|
let tmp_dir = self.tmp(info_hash, false)?;
|
||||||
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
|
||||||
for p in f {
|
for p in f {
|
||||||
|
// build the absolute path for the relative torrent file
|
||||||
|
let o = {
|
||||||
|
let mut t = PathBuf::from(&tmp_dir);
|
||||||
|
t.push(p);
|
||||||
|
t.canonicalize()?
|
||||||
|
};
|
||||||
// make sure preload path is referring to the expected location
|
// make sure preload path is referring to the expected location
|
||||||
let o = p.canonicalize()?;
|
|
||||||
if !o.starts_with(&self.root) || o.is_dir() {
|
if !o.starts_with(&self.root) || o.is_dir() {
|
||||||
bail!("unexpected canonical path `{}`", o.to_string_lossy())
|
bail!("unexpected canonical path `{}`", o.to_string_lossy())
|
||||||
}
|
}
|
||||||
|
|
@ -80,10 +87,9 @@ impl Preload {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// cleanup temporary data
|
// cleanup temporary data
|
||||||
let tmp = self.tmp(info_hash, false)?;
|
if tmp_dir.exists() {
|
||||||
if tmp.exists() {
|
fs::remove_dir_all(&tmp_dir)?;
|
||||||
fs::remove_dir_all(&tmp)?;
|
log::debug!("clean tmp data `{}`", tmp_dir.to_string_lossy())
|
||||||
log::debug!("clean tmp data `{}`", tmp.to_string_lossy())
|
|
||||||
}
|
}
|
||||||
// persist torrent bytes to file (on previous operations success)
|
// persist torrent bytes to file (on previous operations success)
|
||||||
let t = self.torrent(info_hash);
|
let t = self.torrent(info_hash);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue