(ctx caddy.Context)
| 58 | func (xs *Filesystems) Stop() error { return nil } |
| 59 | |
| 60 | func (xs *Filesystems) Provision(ctx caddy.Context) error { |
| 61 | // load the filesystem module |
| 62 | for _, f := range xs.Filesystems { |
| 63 | if len(f.FileSystemRaw) > 0 { |
| 64 | mod, err := ctx.LoadModule(f, "FileSystemRaw") |
| 65 | if err != nil { |
| 66 | return fmt.Errorf("loading file system module: %v", err) |
| 67 | } |
| 68 | f.fileSystem = mod.(fs.FS) |
| 69 | } |
| 70 | // register that module |
| 71 | ctx.Logger().Debug("registering fs", zap.String("fs", f.Key)) |
| 72 | ctx.FileSystems().Register(f.Key, f.fileSystem) |
| 73 | // remember to unregister the module when we are done |
| 74 | xs.defers = append(xs.defers, func() { |
| 75 | ctx.Logger().Debug("unregistering fs", zap.String("fs", f.Key)) |
| 76 | ctx.FileSystems().Unregister(f.Key) |
| 77 | }) |
| 78 | } |
| 79 | return nil |
| 80 | } |
| 81 | |
| 82 | func (f *Filesystems) Cleanup() error { |
| 83 | for _, v := range f.defers { |
nothing calls this directly
no test coverage detected