Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

rc: fix misplaced http server config - fixes #4130

Xiaoxing Yec4572ebc9128
diff --git a/fs/rc/rcserver/rcserver.go b/fs/rc/rcserver/rcserver.go
index bf0e4db90..ac24c6152 100644
--- a/fs/rc/rcserver/rcserver.go
+++ b/fs/rc/rcserver/rcserver.go
@@ -62,12 +62,7 @@ type Server struct {
}
func newServer(opt *rc.Options, mux *http.ServeMux) *Server {
- s := &Server{
- Server: httplib.NewServer(mux, &opt.HTTPOptions),
- opt: opt,
- }
- mux.HandleFunc("/", s.handler)
-
+ fileHandler := http.Handler(nil)
// Add some more mime types which are often missing
_ = mime.AddExtensionType(".wasm", "application/wasm")
_ = mime.AddExtensionType(".js", "application/javascript")
@@ -80,7 +75,7 @@ func newServer(opt *rc.Options, mux *http.ServeMux) *Server {
fs.Logf(nil, "--rc-files overrides --rc-web-gui command\n")
}
fs.Logf(nil, "Serving files from %q", opt.Files)
- s.files = http.FileServer(http.Dir(opt.Files))
+ fileHandler = http.FileServer(http.Dir(opt.Files))
} else if opt.WebUI {
if err := rc.CheckAndDownloadWebGUIRelease(opt.WebGUIUpdate, opt.WebGUIForceUpdate, opt.WebGUIFetchURL, config.CacheDir); err != nil {
log.Fatalf("Error while fetching the latest release of Web GUI: %v", err)
@@ -104,8 +99,16 @@ func newServer(opt *rc.Options, mux *http.ServeMux) *Server {
opt.Serve = true
fs.Logf(nil, "Serving Web GUI")
- s.files = http.FileServer(http.Dir(extractPath))
+ fileHandler = http.FileServer(http.Dir(extractPath))
}
+
+ s := &Server{
+ Server: httplib.NewServer(mux, &opt.HTTPOptions),
+ opt: opt,
+ files: fileHandler,
+ }
+ mux.HandleFunc("/", s.handler)
+
return s
}