From: Ira W. Snyder Date: Mon, 8 Jan 2007 03:58:18 +0000 (-0800) Subject: [JOIN] Fix removal of protected files X-Git-Tag: v2.0.0~5 X-Git-Url: https://irasnyder.com/gitweb/?a=commitdiff_plain;ds=inline;h=663cfde9556accb7d3e24227dec20e2bc84e431d;hp=44cd23f16a5a184adb1d8890633a0e432a2e5636;p=rarslave2.git [JOIN] Fix removal of protected files In the join case, since we are not extracting files, we don't really want to remove the files. So, in this case, remove all files that the delete_regex matches, but not the files that are protected. This fixes the following case: ========================================== X.rar.par2 X.rar.vol0+1.par2 ... X.rar.001 X.rar.002 ... Where X.rar is the only protected file. When the process completes, X.rar will be the only file left. Signed-off-by: Ira W. Snyder --- diff --git a/PAR2Set/Join.py b/PAR2Set/Join.py index b764c49..34c4996 100644 --- a/PAR2Set/Join.py +++ b/PAR2Set/Join.py @@ -42,6 +42,7 @@ __license__ = "GNU GPL v2 (or, at your option, any later version)" # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +import re import os import logging import PAR2Set.Base @@ -97,6 +98,16 @@ class Join (PAR2Set.Base.Base): return rsutil.common.SUCCESS + def find_deleteable_files (self): + """Find all files which are deletable by using the regular expression from the + configuration file""" + + DELETE_REGEX = rsutil.common.config_get_value ('regular expressions', 'delete_regex') + dregex = re.compile (DELETE_REGEX, re.IGNORECASE) + + return [f for f in self.all_files if dregex.match (f) and \ + f not in self.prot_matched_files] + def find_extraction_heads (self): """Find the extraction heads. Since this should not be an extractable set, we return the files which are protected directly by the PAR2 files."""