From 2bfcd1533957e5ab9d48baa9860c4d5de2154a1f Mon Sep 17 00:00:00 2001 From: "Ira W. Snyder" Date: Sat, 27 Jan 2007 11:27:50 -0800 Subject: [PATCH] Bugfix: Fix deletion of .1 files for NoExtract type 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 --- PAR2Set/NoExtract.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/PAR2Set/NoExtract.py b/PAR2Set/NoExtract.py index c065aa3..51ee235 100644 --- a/PAR2Set/NoExtract.py +++ b/PAR2Set/NoExtract.py @@ -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""" -- 2.34.1