Improvements :)
Former-commit-id: c1c1881302a241fdc7140e6aabeb9b49977bd7c6 [formerly 84bb454c2f34baffd9dfa91645b8aff149e52620] [formerly 29e258c7a16db1ca8a3fde7c5e4e3cffc47899a6 [formerly 84ddad027fed623021092d56872ff138bc5ea416]] Former-commit-id: 0018a51df5bc801b783a3ffe17d9f33c504ce094 [formerly 0072c425cd4754e38f30007ab9f5272ea4b40370] Former-commit-id: d298f006e58ef9e4987def4bc354818062b30fcd
This commit is contained in:
11
file.go
11
file.go
@@ -15,7 +15,6 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -56,10 +55,7 @@ type fileInfo struct {
|
||||
|
||||
// A listing is the context used to fill out a template.
|
||||
type listing struct {
|
||||
// The name of the directory (the last element of the path).
|
||||
Name string `json:"-"`
|
||||
// The full path of the request relatively to a File System.
|
||||
Path string `json:"-"`
|
||||
*fileInfo
|
||||
// The items (files and folders) in the path.
|
||||
Items []fileInfo `json:"items"`
|
||||
// The number of directories in the listing.
|
||||
@@ -103,7 +99,7 @@ func getInfo(url *url.URL, c *FileManager, u *User) (*fileInfo, error) {
|
||||
}
|
||||
|
||||
// getListing gets the information about a specific directory and its files.
|
||||
func getListing(u *User, filePath string, baseURL string) (*listing, error) {
|
||||
func getListing(u *User, filePath string, baseURL string, i *fileInfo) (*listing, error) {
|
||||
// Gets the directory information using the Virtual File System of
|
||||
// the user configuration.
|
||||
file, err := u.fileSystem.OpenFile(context.TODO(), filePath, os.O_RDONLY, 0)
|
||||
@@ -155,8 +151,7 @@ func getListing(u *User, filePath string, baseURL string) (*listing, error) {
|
||||
}
|
||||
|
||||
return &listing{
|
||||
Name: path.Base(filePath),
|
||||
Path: filePath,
|
||||
fileInfo: i,
|
||||
Items: fileinfos,
|
||||
NumDirs: dirCount,
|
||||
NumFiles: fileCount,
|
||||
|
||||
Reference in New Issue
Block a user