Преглед на файлове

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 преди 9 години
родител
ревизия
6b27a91b54
променени са 1 файла, в които са добавени 17 реда и са изтрити 1 реда
  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 = []