[tor-commits] [arm/release] fix: existance check before removing paths

atagar at torproject.org atagar at torproject.org
Sun Sep 25 21:38:22 UTC 2011


commit 3af68f600f58f3a791958a94d274d70676efeec7
Author: Damian Johnson <atagar at torproject.org>
Date:   Wed Jul 27 06:19:13 2011 -0700

    fix: existance check before removing paths
---
 src/resources/torrcOverride/override.py |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/resources/torrcOverride/override.py b/src/resources/torrcOverride/override.py
index 3e42892..21e6b28 100755
--- a/src/resources/torrcOverride/override.py
+++ b/src/resources/torrcOverride/override.py
@@ -102,18 +102,19 @@ def remove():
   print "removing %s group..." % GROUP
   os.system("delgroup --quiet %s" % GROUP)
   
-  # might not exist since this is compiled and placed separately
-  try:
-    print "removing '/bin/torrc-override'..."
-    os.remove("/bin/torrc-override")
-  except OSError:
-    print "  no such path"
+  if os.path.exists("/bin/torrc-override"):
+    try:
+      print "removing '/bin/torrc-override'..."
+      os.remove("/bin/torrc-override")
+    except OSError, exc:
+      print "  unsuccessful: %s" % exc
   
-  try:
-    print "removing '/var/lib/tor-arm'..."
-    shutil.rmtree("/var/lib/tor-arm/")
-  except Exception, exc:
-    print "  unsuccessful: %s" % exc
+  if os.path.exists("/var/lib/tor-arm/"):
+    try:
+      print "removing '/var/lib/tor-arm'..."
+      shutil.rmtree("/var/lib/tor-arm/")
+    except Exception, exc:
+      print "  unsuccessful: %s" % exc
 
 def replaceTorrc():
   orig_uid = os.getuid()





More information about the tor-commits mailing list