Find implements backend.Reader
(_ context.Context, keypath backend.KeyPath, f backend.FindFunc)
| 196 | |
| 197 | // Find implements backend.Reader |
| 198 | func (rw *Backend) Find(_ context.Context, keypath backend.KeyPath, f backend.FindFunc) (err error) { |
| 199 | path := rw.rootPath(keypath) |
| 200 | fff := os.DirFS(path) |
| 201 | err = fs.WalkDir(fff, ".", func(path string, d fs.DirEntry, err error) error { |
| 202 | if err != nil { |
| 203 | return err |
| 204 | } |
| 205 | |
| 206 | if d.IsDir() { |
| 207 | return nil |
| 208 | } |
| 209 | |
| 210 | info, err := d.Info() |
| 211 | if err != nil { |
| 212 | return err |
| 213 | } |
| 214 | |
| 215 | tenantFilePath := filepath.Join(filepath.Join(keypath...), path) |
| 216 | opts := backend.FindMatch{ |
| 217 | Key: tenantFilePath, |
| 218 | Modified: info.ModTime(), |
| 219 | } |
| 220 | |
| 221 | f(opts) |
| 222 | |
| 223 | return nil |
| 224 | }) |
| 225 | |
| 226 | return |
| 227 | } |
| 228 | |
| 229 | // Read implements backend.Reader |
| 230 | func (rw *Backend) Read(ctx context.Context, name string, keypath backend.KeyPath, _ *backend.CacheInfo) (io.ReadCloser, int64, error) { |