[library-web] do not fail cleaning stuff from extracts when directory doesn't exist



commit d1e81c2dba06dfb9e336d2fdff73eb57dcd5474a
Author: Frédéric Péters <fpeters 0d be>
Date:   Mon Jan 27 14:36:07 2014 +0000

    do not fail cleaning stuff from extracts when directory doesn't exist

 src/lgo.py |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/src/lgo.py b/src/lgo.py
index 03c34dd..5ad3f61 100755
--- a/src/lgo.py
+++ b/src/lgo.py
@@ -464,20 +464,22 @@ class Lgo(App):
             return []
 
         # Step 0: remove old occurences of module extracts
-        for extract_filename in os.listdir(os.path.join(app.config.private_dir, 'extracts')):
-            if extract_filename.endswith('.extract-stamp'):
-                continue
-            if extract_filename == tarball_name:
-                continue
-            if not extract_filename.startswith(tarname_without_minor):
-                continue
-            extract_dir = os.path.join(app.config.private_dir, 'extracts', extract_filename)
-            try:
-                shutil.rmtree(extract_dir)
-            except OSError:
-                continue
-            if os.path.exists(extract_dir + '.extract-stamp'):
-                os.unlink(extract_dir + '.extract-stamp')
+        for basedir, dirnames, filenames in os.walk(os.path.join(app.config.private_dir, 'extracts')):
+            for extract_filename in filenames:
+                if extract_filename.endswith('.extract-stamp'):
+                    continue
+                if extract_filename == tarball_name:
+                    continue
+                if not extract_filename.startswith(tarname_without_minor):
+                    continue
+                extract_dir = os.path.join(app.config.private_dir, 'extracts', extract_filename)
+                try:
+                    shutil.rmtree(extract_dir)
+                except OSError:
+                    continue
+                if os.path.exists(extract_dir + '.extract-stamp'):
+                    os.unlink(extract_dir + '.extract-stamp')
+            break
 
         if self.config.fast_mode:
             ext_dirname = os.path.join(app.config.private_dir, 'extracts', tarball_name)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]