From 553bffb4f0a4ce324c6f1882de5b61301705b799 Mon Sep 17 00:00:00 2001 From: yggverse Date: Fri, 8 Aug 2025 03:11:53 +0300 Subject: [PATCH] persist torrent bytes to file on the last step --- src/preload.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/preload.rs b/src/preload.rs index 08f9bfc..f01dbe4 100644 --- a/src/preload.rs +++ b/src/preload.rs @@ -41,10 +41,6 @@ impl Preload { persist_files: Option>, ) -> Result<()> { validate_info_hash(info_hash)?; - // persist torrent bytes to file - let t = self.torrent(info_hash); - fs::write(&t, torrent_bytes)?; - log::debug!("persist torrent bytes for `{}`", t.to_string_lossy()); // persist preload files let mut d = PathBuf::from(&self.root); d.push(info_hash); @@ -90,6 +86,10 @@ impl Preload { fs::remove_dir_all(&tmp)?; log::debug!("clean tmp data `{}`", tmp.to_string_lossy()) } + // persist torrent bytes to file (on previous operations success) + let t = self.torrent(info_hash); + fs::write(&t, torrent_bytes)?; + log::debug!("persist torrent bytes for `{}`", t.to_string_lossy()); Ok(()) }