Skip to content

Commit

Permalink
ディレクトリ数が合わないパターンがあったため修正
Browse files Browse the repository at this point in the history
  • Loading branch information
ddddddO committed Sep 30, 2023
1 parent ca2b12e commit c427104
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package internal
import (
"fmt"
"path/filepath"
"strings"
)

type counter struct {
Expand All @@ -19,8 +20,11 @@ func newCounter() *counter {

func (c *counter) count(path string) {
dir, file := filepath.Split(path)
splited := strings.Split(dir, "/")
if len(dir) > 0 {
c.dirs[dir] = struct{}{}
for i := range splited {
c.dirs[filepath.Join(splited[:i+1]...)] = struct{}{}
}
}
if len(file) > 0 {
c.files[path] = struct{}{}
Expand Down

0 comments on commit c427104

Please sign in to comment.