]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Simply should_ignore_file helper function
authorDavid Stainton <dstainton415@gmail.com>
Mon, 14 Sep 2015 04:29:56 +0000 (06:29 +0200)
committerDavid Stainton <dstainton415@gmail.com>
Mon, 14 Sep 2015 04:29:56 +0000 (06:29 +0200)
src/allmydata/magicpath.py

index e2728421f6e7c8fbe437dbfa7b1d7840754498e4..b072b463298722ed8c4f445ac0a0d75c2c83b5ef 100644 (file)
@@ -9,22 +9,15 @@ def magic2path(path):
     return re.sub(ur'@[_@]', lambda m: {u'@_': u'/', u'@@': u'@'}[m.group(0)], path)
 
 
-IGNORE_SUFFIXES = ['.backup', '.tmp', '.conflicted']
-IGNORE_PREFIXES = ['.']
+IGNORE_SUFFIXES = [u'.backup', u'.tmp', u'.conflicted']
+IGNORE_PREFIXES = [u'.']
 
 def should_ignore_file(path_u):
     for suffix in IGNORE_SUFFIXES:
         if path_u.endswith(suffix):
             return True
-    while True:
-        head, tail = os.path.split(path_u)
-        if tail != "":
-            for prefix in IGNORE_PREFIXES:
-                if tail.startswith(prefix):
-                    return True
-                else:
-                    path_u = head
-        else:
-            if head == "":
-                return False
+    while path_u != u"":
+        path_u, tail_u = os.path.split(path_u)
+        if tail_u.startswith(u"."):
+            return True
     return False