From 65860664b6b841fca3ecdc0db0e7502d29bfebd0 Mon Sep 17 00:00:00 2001 From: raul Date: Mon, 17 Jun 2024 12:46:04 +0200 Subject: [PATCH] Allow accessing parent folders easily --- cmd/httpServer.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cmd/httpServer.go b/cmd/httpServer.go index 45bc2af..e42c9e8 100644 --- a/cmd/httpServer.go +++ b/cmd/httpServer.go @@ -77,14 +77,28 @@ func listFiles(c *gin.Context) { return } var list string + currentLocation := fmt.Sprintf("Current location: %v
", path) + list += currentLocation + + split := strings.Split(path, "/") + parentFolder := strings.Join(split[:len(split)-1], "/") + if parentFolder == "" { + parentFolder = "/" + } + + parentFolderLink := fmt.Sprintf("../
", + client.ClientID, parentFolder) + list += parentFolderLink + for _, v := range resp.FileList.File { - isDir := "" if v.IsFolder == true { - isDir = "/" + entry := fmt.Sprintf("[DIR] %v
", + client.ClientID, v.FullPath, v.Name) + list += entry + } else { + entry := fmt.Sprintf("%v
", v.Name) + list += entry } - entry := fmt.Sprintf("

%v%v

", - client.ClientID, v.FullPath, v.FullPath, isDir) - list += entry } c.String(http.StatusOK, list)