Add support for Join sets where the parity protects the split files
[rarslave2.git] / rarslave.py
index edd34ce..20c0288 100755 (executable)
@@ -43,7 +43,7 @@ import PAR2Set
 class RarslaveConfig(object):
 
     DEFAULT_CONFIG_FILE = PAR2Set.utils.absolutePath(
-        os.path.join('~', '.config', 'rarslave2', 'rarslave2.conf'))
+        os.path.join('~', '.config', 'rarslave', 'rarslave.conf'))
 
     def __init__(self, fileName=DEFAULT_CONFIG_FILE):
 
@@ -252,13 +252,14 @@ def findUniqueSets(directory, files):
 
         try:
             c = PAR2Set.CompareSet(directory, f)
-
-            if c not in s:
-                s.append(c)
         except:
             # We just ignore any errors that happen, such as
             # parsing the PAR file
             pass
+        else:
+            # Ok, we got a valid set, add it to s
+            if c not in s:
+                s.append(c)
 
     return s
 
@@ -268,6 +269,7 @@ def findUniqueSets(directory, files):
 def runEachType(cs, options):
 
     types = (
+        PAR2Set.JoinProtected,
         PAR2Set.Join,
         PAR2Set.ZIP,
         PAR2Set.OldRAR,
@@ -283,21 +285,22 @@ def runEachType(cs, options):
     for t in types:
         try:
             instance = t(cs, options)
-            detected = True
-            logging.debug('%s detected for %s' % (t.__name__, cs.parityFile))
         except TypeError:
             logging.debug('%s not detected for %s' % (t.__name__, cs.parityFile))
             continue
+        else:
+            detected = True
+            logging.debug('%s detected for %s' % (t.__name__, cs.parityFile))
 
         # We detected something, try to run it
         try:
             instance.run()
-            logging.info('Success: %s' % instance)
-
-            # Leave early, we're done
-            return
         except (OSError, CalledProcessError):
             logging.critical('Failure: %s' % instance)
+        else:
+            # Leave early, we're done
+            logging.info('Success: %s' % instance)
+            return
 
     # Check that at least one detection worked
     if not detected:
@@ -321,8 +324,12 @@ def runDirectory(directory, files, options):
     for cs in sets:
         try:
             runEachType(cs, options)
-        except:
+        except Exception, e:
+            import traceback
             logging.error('Unknown Exception: %s' % cs.parityFile)
+            logging.error('===== BEGIN Bactrace =====')
+            [logging.error(l) for l in traceback.format_exc(e).split('\n')]
+            logging.error('===== END Bactrace =====')
 
 ################################################################################