From c130e98c7cf39e42d19ed9bf131c27d9322b7b3f Mon Sep 17 00:00:00 2001 From: Mickael Kerjean Date: Tue, 30 Apr 2019 14:27:50 +1000 Subject: [PATCH] maintenance (cleanup): remove dead code --- server/ctrl/config.go | 19 ------------------- server/ctrl/static.go | 37 ++++++------------------------------- server/main.go | 1 - 3 files changed, 6 insertions(+), 51 deletions(-) diff --git a/server/ctrl/config.go b/server/ctrl/config.go index 8a958677..cedcbb1c 100644 --- a/server/ctrl/config.go +++ b/server/ctrl/config.go @@ -13,27 +13,8 @@ import ( var ( logpath = filepath.Join(GetCurrentDir(), LOG_PATH, "access.log") configpath = filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json") - pluginpath = filepath.Join(GetCurrentDir(), PLUGIN_PATH) ) -func FetchPluginsHandler(ctx App, res http.ResponseWriter, req *http.Request) { - f, err := os.OpenFile(pluginpath, os.O_RDONLY, os.ModePerm) - if err != nil { - SendErrorResult(res, err) - return - } - files, err := f.Readdir(0) - if err != nil { - SendErrorResult(res, err) - return - } - plugins := make([]string, 0) - for i := 0; i < len(files); i++ { - plugins = append(plugins, files[i].Name()) - } - SendSuccessResults(res, plugins) -} - func FetchLogHandler(ctx App, res http.ResponseWriter, req *http.Request) { file, err := os.OpenFile(logpath, os.O_RDONLY, os.ModePerm) if err != nil { diff --git a/server/ctrl/static.go b/server/ctrl/static.go index bda0b03e..e950c22d 100644 --- a/server/ctrl/static.go +++ b/server/ctrl/static.go @@ -75,42 +75,17 @@ func AboutHandler(ctx App, res http.ResponseWriter, req *http.Request) { -

{{index .App 0}}
({{index .App 1}})

-

{{range .Plugins}} - {{ index . 0 }} ({{ index . 1 }})
{{end}} -

+

{{index .App 0}}
({{index .App 1}} - {{index .App 2}})

` t, _ := template.New("about").Parse(page) t.Execute(res, struct { App []string - Plugins [][]string - }{ - App: []string{"Filestash " + APP_VERSION + "." + BUILD_NUMBER, hashFile(filepath.Join(GetCurrentDir(), "/filestash"), 6)}, - Plugins: func () [][]string { - plugins := make([][]string, 1) - plugins[0] = []string { - "config.json", - hashFile(filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json"), 6), - } - pPath := filepath.Join(GetCurrentDir(), PLUGIN_PATH) - file, err := os.Open(pPath); - if err != nil { - return plugins - } - files, err := file.Readdir(0); - if err != nil { - return plugins - } - for i:=0; i < len(files); i++ { - plugins = append(plugins, []string{ - files[i].Name(), - hashFile(pPath + "/" + files[i].Name(), 6), - }) - } - return plugins - }(), - }) + }{ []string{ + "Filestash " + APP_VERSION + "." + BUILD_NUMBER, + hashFile(filepath.Join(GetCurrentDir(), "/filestash"), 6), + hashFile(filepath.Join(GetCurrentDir(), CONFIG_PATH, "config.json"), 6), + }}) } func hashFile (path string, n int) string { diff --git a/server/main.go b/server/main.go index 221cd5ad..e0a267fa 100644 --- a/server/main.go +++ b/server/main.go @@ -46,7 +46,6 @@ func Init(a *App) { admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionGet, middlewares, *a)).Methods("GET") admin.HandleFunc("/session", NewMiddlewareChain(AdminSessionAuthenticate, middlewares, *a)).Methods("POST") middlewares = []Middleware{ ApiHeaders, AdminOnly, SecureAjax } - admin.HandleFunc("/plugin", NewMiddlewareChain(FetchPluginsHandler, middlewares, *a)).Methods("GET") admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigHandler, middlewares, *a)).Methods("GET") admin.HandleFunc("/config", NewMiddlewareChain(PrivateConfigUpdateHandler, middlewares, *a)).Methods("POST") middlewares = []Middleware{ IndexHeaders }