mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: refactor site handler to take cache dir (#21918)
relates to: https://github.com/coder/internal/issues/1300 Refactors the options to the site handler to take the cache directory, rather than expecting the caller to call `ExtractOrReadBinFS` and pass the results. This is important in this stack because we need direct access to the cache directory for compressed file caching.
This commit is contained in:
+8
-4
@@ -89,11 +89,15 @@ func (h *binHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
http.FileServer(h.binFS).ServeHTTP(rw, r)
|
||||
}
|
||||
|
||||
func newBinHandler(options *Options) *binHandler {
|
||||
return &binHandler{
|
||||
binFS: options.BinFS,
|
||||
metadataCache: newBinMetadataCache(options.BinFS, options.BinHashes),
|
||||
func newBinHandler(options *Options) (*binHandler, error) {
|
||||
binFS, binHashes, err := ExtractOrReadBinFS(options.CacheDir, options.SiteFS)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("extract or read bin filesystem: %w", err)
|
||||
}
|
||||
return &binHandler{
|
||||
binFS: binFS,
|
||||
metadataCache: newBinMetadataCache(binFS, binHashes),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ExtractOrReadBinFS checks the provided fs for compressed coder binaries and
|
||||
|
||||
Reference in New Issue
Block a user