Bläddra i källkod

Actually, when we're told to configure, move the old 'nodes' dir

This makes me happier than just removing it, and shouldn't kill too
many people's hard drives.
Nick Mathewson 10 år sedan
förälder
incheckning
6b27a91b54
1 ändrade filer med 17 tillägg och 1 borttagningar
  1. 17 1
      lib/chutney/TorNet.py

+ 17 - 1
lib/chutney/TorNet.py

@@ -749,12 +749,28 @@ class Network(object):
         self._nextnodenum += 1
         self._nodes.append(n)
 
+    def move_aside_nodes(self):
+        nodesdir = os.path.join(os.getcwd(),'net','nodes')
+
+        if not os.path.exists(nodesdir):
+            return
+
+        newdir = newdirbase = "%s.%d" % (nodesdir, time.time())
+        i = 0
+        while os.path.exists(newdir):
+            i += 1
+            newdir = "%s.%d" %(newdirbase, i)
+
+        print ("NOTE: renaming %r to %r"%(nodesdir, newdir))
+        os.rename(nodesdir, newdir)
+
     def _checkConfig(self):
         for n in self._nodes:
             n.getBuilder().checkConfig(self)
 
     def configure(self):
-        shutil.rmtree(os.path.join(os.getcwd(),'net','nodes'),ignore_errors=True)
+        # shutil.rmtree(os.path.join(os.getcwd(),'net','nodes'),ignore_errors=True)
+        self.move_aside_nodes()
         network = self
         altauthlines = []
         bridgelines = []