[PAR2SET_JOIN] Fix detection code
[rarslave2.git] / PAR2Set_EXTRACTFIRST.py
1 #!/usr/bin/env python
2 # vim: set ts=4 sts=4 sw=4 textwidth=92:
3
4 import PAR2Set
5 from RarslaveCommon import *
6
7 #
8 # This is another base class for types that must
9 # run the extraction routine before the repair routine
10 #
11 # It will detect sets like the following:
12 # X.par2
13 # X.vol0+1.par2
14 # X.vol1+2.par2
15 # X.part01.rar
16 # X.part02.rar
17 # X.part03.rar
18 #
19 # Where the PAR2 files protect a file named X.avi, but not the X.part01.rar
20 # (and other) files.
21 #
22
23 class PAR2Set_EXTRACTFIRST (PAR2Set.PAR2Set):
24
25         def runAll (self):
26
27                 # Extraction Stage
28                 ret = self.runExtract ()
29
30                 if ret != SUCCESS:
31                         fatalMessage ('Extraction stage failed for: %s' % self.p2file)
32                         return -EEXTRACT
33
34                 self.update_matches ()
35
36                 # Repair Stage
37                 ret = self.runVerifyAndRepair ()
38
39                 if ret != SUCCESS:
40                         fatalMessage ('Repair stage failed for: %s' % self.p2file)
41                         return -ECHECK
42
43                 self.update_matches ()
44
45                 # Deletion Stage
46                 ret = self.runDelete ()
47
48                 if ret != SUCCESS:
49                         fatalMessage ('Deletion stage failed for: %s' % self.p2file)
50                         return -EDELETE
51
52                 normalMessage ('Successfully completed: %s' % self.p2file)
53                 return SUCCESS
54