Sfoglia il codice sorgente

net/tor: Add missing cache dir layout to TorListener

parazyd 1 anno fa
parent
commit
10edfbdf1a
1 ha cambiato i file con 13 aggiunte e 2 eliminazioni
  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...");
                 debug!(target: "net::tor::do_listen", "Bootstrapping...");
                 if let Some(datadir) = &self.datastore {
                 if let Some(datadir) = &self.datastore {
                     let datadir = expand_path(datadir).unwrap();
                     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()
                         .build()
                         .unwrap();
                         .unwrap();
 
 
@@ -194,7 +205,7 @@ impl TorListener {
             })
             })
             .await
             .await
         {
         {
-            Ok(client) => client,
+            Ok(client) => client.isolated_client(),
             Err(e) => {
             Err(e) => {
                 warn!(target: "net::tor::do_listen", "{}", e.report());
                 warn!(target: "net::tor::do_listen", "{}", e.report());
                 return Err(io::Error::other("Internal Tor error, see logged warning"))
                 return Err(io::Error::other("Internal Tor error, see logged warning"))