Fixes #141: Wrong section in multi level structure
authorRuben <ruben.nellen@gmail.com>
Thu, 28 Nov 2013 14:27:09 +0000 (15:27 +0100)
committerspf13 <steve.francia@gmail.com>
Mon, 16 Dec 2013 22:40:33 +0000 (17:40 -0500)
source/filesystem.go

index abec4bad4862100a0d1daf45952157e66ff41910..f44f003f08fd549f4a68ca932d389a0a48afee1e 100644 (file)
@@ -6,6 +6,7 @@ import (
        "os"
        "path"
        "path/filepath"
+       "strings"
 )
 
 type Input interface {
@@ -41,8 +42,11 @@ func (f *Filesystem) add(name string, reader io.Reader) (err error) {
                return err
        }
 
+       // section should be the first part of the path
        dir, logical := path.Split(name)
-       _, section := path.Split(path.Dir(name))
+       parts := strings.Split(dir, "/")
+       section := parts[0]
+
        if section == "." {
                section = ""
        }
@@ -54,6 +58,7 @@ func (f *Filesystem) add(name string, reader io.Reader) (err error) {
                Section:     section,
                Dir:         dir,
        })
+
        return
 }