|
|
@@ -8,7 +8,7 @@ import ( |
|
|
|
"github.com/casbin/casbase/util" |
|
|
|
) |
|
|
|
|
|
|
|
func (store *Store) createPathIfNotExisted(tokens []string, lastModifiedTime string, lastIsLeaf bool) { |
|
|
|
func (store *Store) createPathIfNotExisted(tokens []string, lastModifiedTime string, isLeaf bool) { |
|
|
|
currentFile := store.FileTree |
|
|
|
if currentFile == nil { |
|
|
|
currentFile = &File{ |
|
|
@@ -36,16 +36,16 @@ func (store *Store) createPathIfNotExisted(tokens []string, lastModifiedTime str |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
isLeaf := false |
|
|
|
isLeafTmp := false |
|
|
|
if i == len(tokens)-1 { |
|
|
|
isLeaf = lastIsLeaf |
|
|
|
isLeafTmp = isLeaf |
|
|
|
} |
|
|
|
|
|
|
|
key := strings.Join(tokens[:i+1], "/") |
|
|
|
newFile := &File{ |
|
|
|
Key: key, |
|
|
|
Title: token, |
|
|
|
IsLeaf: isLeaf, |
|
|
|
IsLeaf: isLeafTmp, |
|
|
|
Children: []*File{}, |
|
|
|
ChildrenMap: map[string]*File{}, |
|
|
|
} |
|
|
@@ -65,13 +65,13 @@ func (store *Store) Populate() { |
|
|
|
for _, object := range objects { |
|
|
|
lastModifiedTime := object.LastModified.Local().Format(time.RFC3339) |
|
|
|
|
|
|
|
lastIsLeaf := true |
|
|
|
isLeaf := true |
|
|
|
if object.Key[len(object.Key)-1] == '/' { |
|
|
|
lastIsLeaf = false |
|
|
|
isLeaf = false |
|
|
|
} |
|
|
|
|
|
|
|
tokens := strings.Split(strings.Trim(object.Key, "/"), "/") |
|
|
|
store.createPathIfNotExisted(tokens, lastModifiedTime, lastIsLeaf) |
|
|
|
store.createPathIfNotExisted(tokens, lastModifiedTime, isLeaf) |
|
|
|
|
|
|
|
//fmt.Printf("%s, %d, %v\n", object.Key, object.Size, object.LastModified) |
|
|
|
} |
|
|
|