changeset 4109:e88baf535b48

fix backup action configuration (broke on windows due to backslashes in e.g. cache_dir), try 2. cfg.backup_exclude is now just a function of filename, telling whether the file should be excluded. By default, no file is excluded.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 19 Sep 2008 21:41:40 +0200
parents 1cd493d5e113
children c348b55c5122
files MoinMoin/action/backup.py MoinMoin/config/multiconfig.py docs/CHANGES
diffstat 3 files changed, 13 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/backup.py	Thu Sep 18 22:19:44 2008 +0200
+++ b/MoinMoin/action/backup.py	Fri Sep 19 21:41:40 2008 +0200
@@ -22,13 +22,13 @@
 from MoinMoin.support import tarfile
 
 
-def addFiles(path, tar, exclude_regex):
+def addFiles(path, tar, exclude_func):
     """ Add files in path to tar """
     for root, dirs, files in os.walk(path):
         files.sort() # sorted page revs may compress better
         for name in files:
             path = os.path.join(root, name)
-            if exclude_regex.search(path):
+            if exclude_func(path):
                 continue
             tar.add(path)
 
@@ -45,7 +45,7 @@
     # allow GNU tar's longer file/pathnames
     tar.posix = False
     for path in request.cfg.backup_include:
-        addFiles(path, tar, request.cfg.cache.backup_exclude_regex)
+        addFiles(path, tar, request.cfg.backup_exclude)
     tar.close()
 
 
--- a/MoinMoin/config/multiconfig.py	Thu Sep 18 22:19:44 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Fri Sep 19 21:41:40 2008 +0200
@@ -325,9 +325,6 @@
         # e.g u'%(page_front_page)s' % self
         self.navi_bar = [elem % self for elem in self.navi_bar]
 
-        # compile regex for backup exclusions and cache it
-        self.cache.backup_exclude_regex = re.compile("|".join(self.backup_exclude))
-
         # check if python-xapian is installed
         if self.xapian_search:
             try:
@@ -1204,13 +1201,7 @@
       ('compression', 'gz', 'What compression to use for the backup ("gz" or "bz2").'),
       ('users', [], 'List of trusted user names who are allowed to get a backup.'),
       ('include', [], 'List of pathes to backup.'),
-      ('exclude',
-       [
-        r"(.+\.py(c|o)$)",
-        r"%(/)spages%(/)s.+%(/)scache%(/)s[^%(/)s]+$" % {'/': os.sep},
-        r"%(/)s(edit-lock|event-log|\.DS_Store)$" % {'/': os.sep},
-       ],
-       'List of regular expressions matching files that should be excluded from the backup.'),
+      ('exclude', lambda filename: False, 'Function f(filename) that tells whether a file should be excluded from backup. By default, nothing is excluded.'),
     )),
 }
 
--- a/docs/CHANGES	Thu Sep 18 22:19:44 2008 +0200
+++ b/docs/CHANGES	Fri Sep 19 21:41:40 2008 +0200
@@ -102,11 +102,15 @@
     * user_autocreate setting was removed from wiki configuration and replaced
       by a autocreate=<boolean> parameter of the auth objects that support user
       profile auto creation.
-    * backup action: backup_exclude does not do %(placeholder)s expansion any
-      more, because of unfixable problems with regex special characters in
-      pathes (e.g. backslashes in windows pathes). The %(cache_dir)s placeholder
-      was removed because of this.
-
+    * backup action: backup_exclude (default: "do not exclude anything") is now
+      a function f(filename) that tells whether a file should be excluded from
+      backup.
+      You can get the old regex exclusion functionality by using:
+      backup_exclude = re.compile(your_regex).search
+      Be careful with your regex, you might need to use re.escape() to escape
+      characters that have a special meaning in regexes (e.g.: \.[] etc.).
+      If in doubt, maybe just leave backup_exclude at the default and don't
+      exclude anything.
 
 Version 1.7.2:
   Fixes: