Bugfix: Fix deletion of .1 files for NoExtract type
[rarslave2.git] / PAR2Set / NoExtract.py
index c065aa3..51ee235 100644 (file)
@@ -64,6 +64,32 @@ class NoExtract (PAR2Set.Base.Base):
        def __repr__ (self):
                return 'NoExtract'
 
+       def update_matches (self):
+               """Updates the contents of instance variables with the current in-filesystem state.
+                  This should be run after any operation which can create or delete files."""
+
+               # A NoExtract set is very different from the other sets in this regard. Since we
+               # don't really have a single file that is protected, it's not likely that "normal"
+               # name matching will work as expected.
+               #
+               # Because of this, we will try to find name matches for every single name that is
+               # protected by this set. This will help to detect .1 files that are produced when
+               # repairing this kind of set.
+
+               # Find "normal" name matched files
+               self.name_matched_files = rsutil.common.find_name_matches (self.dir, self.basename)
+
+               # Find "extra" name matched files
+               for f in self.prot_matched_files:
+                       f_basename = rsutil.common.get_basename (f)
+                       f_matches = rsutil.common.find_name_matches (self.dir, f_basename)
+
+                       self.name_matched_files = rsutil.common.no_duplicates (self.name_matched_files +
+                                       f_matches)
+
+               # Update the all_files part now
+               self.all_files = rsutil.common.no_duplicates (self.name_matched_files + self.prot_matched_files)
+
        def runAll (self):
                """Run the Repair and Deletion stages, omitting the Extraction stage"""