Bugfix: Fix deletion of .1 files for NoExtract type v2.0.0
authorIra W. Snyder <devel@irasnyder.com>
Sat, 27 Jan 2007 19:27:50 +0000 (11:27 -0800)
committerIra W. Snyder <devel@irasnyder.com>
Sat, 27 Jan 2007 19:27:50 +0000 (11:27 -0800)
The NoExtract type failed to delete files that were produced during the
repair stage. These files typically end with the extension ".1". This patch
updates the update_matches() function to handle this case.

Note that it is possible that other sets will have this problem, in which
case this patch could be ported to the PAR2Set.Base.Base class, but I have
never seen such a case in the wild.

Signed-off-by: Ira W. Snyder <devel@irasnyder.com>
PAR2Set/NoExtract.py

index c065aa3..51ee235 100644 (file)
@@ -64,6 +64,32 @@ class NoExtract (PAR2Set.Base.Base):
        def __repr__ (self):
                return 'NoExtract'
 
        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"""
 
        def runAll (self):
                """Run the Repair and Deletion stages, omitting the Extraction stage"""