Selaa lähdekoodia

net/tor: Add missing cache dir layout to TorListener

parazyd 1 vuosi sitten
vanhempi
sitoutus
10edfbdf1a
1 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 13 2
      src/net/transport/tor.rs

+ 13 - 2
src/net/transport/tor.rs

@@ -182,8 +182,19 @@ impl TorListener {
                 debug!(target: "net::tor::do_listen", "Bootstrapping...");
                 if let Some(datadir) = &self.datastore {
                     let datadir = expand_path(datadir).unwrap();
+                    let arti_data = datadir.join("arti-data");
+                    let arti_cache = datadir.join("arti-cache");
 
-                    let config = TorClientConfigBuilder::from_directories(datadir.clone(), datadir)
+                    // Reset arti folders.
+                    // We unwrap here so we panic in case of errors.
+                    if arti_data.exists() {
+                        remove_dir_all(&arti_data).unwrap();
+                    }
+                    if arti_cache.exists() {
+                        remove_dir_all(&arti_cache).unwrap();
+                    }
+
+                    let config = TorClientConfigBuilder::from_directories(arti_data, arti_cache)
                         .build()
                         .unwrap();
 
@@ -194,7 +205,7 @@ impl TorListener {
             })
             .await
         {
-            Ok(client) => client,
+            Ok(client) => client.isolated_client(),
             Err(e) => {
                 warn!(target: "net::tor::do_listen", "{}", e.report());
                 return Err(io::Error::other("Internal Tor error, see logged warning"))