Don't process dotfiles
authorChristoph Burgdorf <christoph.burgdorf@bvsn.org>
Mon, 14 Apr 2014 21:25:54 +0000 (23:25 +0200)
committerspf13 <steve.francia@gmail.com>
Sun, 27 Apr 2014 05:17:54 +0000 (23:17 -0600)
This commit makes it so that not only files
but also folders which start with a dot
are ignored.

Fixes #239

source/content_directory_test.go
source/filesystem.go

index d8ed8128ab87a9bbe2bf7b801b3314bc95da54a5..aab3410bbe76e18a90738ae4f9f081f50c62aaec 100644 (file)
@@ -4,11 +4,13 @@ import (
        "testing"
 )
 
-func TestIgnoreDotFiles(t *testing.T) {
+func TestIgnoreDotFilesAndDirectories(t *testing.T) {
        tests := []struct {
                path   string
                ignore bool
        }{
+               {".foobar/", true },
+               {"foobar/.barfoo/", true },
                {"barfoo.md", false},
                {"foobar/barfoo.md", false},
                {"foobar/.barfoo.md", true},
@@ -22,7 +24,7 @@ func TestIgnoreDotFiles(t *testing.T) {
        }
 
        for _, test := range tests {
-               if ignored := ignoreDotFile(test.path); test.ignore != ignored {
+               if ignored := isNonProcessablePath(test.path); test.ignore != ignored {
                        t.Errorf("File not ignored.  Expected: %t, got: %t", test.ignore, ignored)
                }
        }
index abec6ca6e332386542f47e7b5bf97b0a5b9d278d..3a176d7ba59ef7b69f2f788e4634e011967a6fe3 100644 (file)
@@ -87,12 +87,12 @@ func (f *Filesystem) captureFiles() {
                }
 
                if fi.IsDir() {
-                       if f.avoid(filePath) {
+                       if f.avoid(filePath) || isNonProcessablePath(filePath) {
                                return filepath.SkipDir
                        }
                        return nil
                } else {
-                       if ignoreDotFile(filePath) {
+                       if isNonProcessablePath(filePath) {
                                return nil
                        }
                        data, err := ioutil.ReadFile(filePath)
@@ -116,7 +116,7 @@ func (f *Filesystem) avoid(filePath string) bool {
        return false
 }
 
-func ignoreDotFile(filePath string) bool {
+func isNonProcessablePath(filePath string) bool {
        base := filepath.Base(filePath)
        if base[0] == '.' {
                return true