MCPcopy Index your code
hub / github.com/FloatTech/AnimeAPI / rollLocal

Method rollLocal

setu/pool.go:135–156  ·  view source on GitHub ↗
(d string)

Source from the content-addressed store, hash-verified

133}
134
135func (p *Pool) rollLocal(d string) (string, error) {
136 files, err := os.ReadDir(d)
137 if err != nil {
138 return "", err
139 }
140 if len(files) == 0 {
141 return "", ErrEmptyType
142 }
143 if len(files) == 1 {
144 if files[0].IsDir() {
145 return "", ErrEmptyType
146 }
147 return d + "/" + files[0].Name(), nil
148 }
149 for c := 0; c < 128; c++ {
150 f := files[rand.Intn(len(files))]
151 if !f.IsDir() {
152 return d + "/" + f.Name(), nil
153 }
154 }
155 return "", ErrEmptyType
156}

Callers 2

RollMethod · 0.95
RollLocalMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected