mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
WebClient: add an id field to files list to simplify UI logic
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -1009,7 +1009,7 @@ func (s *httpdServer) handleShareGetDirContents(w http.ResponseWriter, r *http.R
|
||||
}
|
||||
defer lister.Close()
|
||||
|
||||
dataGetter := func(limit, _ int) ([]byte, int, error) {
|
||||
dataGetter := func(limit, offset int) ([]byte, int, error) {
|
||||
contents, err := lister.Next(limit)
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
@@ -1018,11 +1018,12 @@ func (s *httpdServer) handleShareGetDirContents(w http.ResponseWriter, r *http.R
|
||||
return nil, 0, err
|
||||
}
|
||||
results := make([]map[string]any, 0, len(contents))
|
||||
for _, info := range contents {
|
||||
for idx, info := range contents {
|
||||
if !info.Mode().IsDir() && !info.Mode().IsRegular() {
|
||||
continue
|
||||
}
|
||||
res := make(map[string]any)
|
||||
res["id"] = offset + idx + 1
|
||||
if info.IsDir() {
|
||||
res["type"] = "1"
|
||||
res["size"] = ""
|
||||
@@ -1217,7 +1218,7 @@ func (s *httpdServer) handleClientGetDirContents(w http.ResponseWriter, r *http.
|
||||
defer lister.Close()
|
||||
|
||||
dirTree := r.URL.Query().Get("dirtree") == "1"
|
||||
dataGetter := func(limit, _ int) ([]byte, int, error) {
|
||||
dataGetter := func(limit, offset int) ([]byte, int, error) {
|
||||
contents, err := lister.Next(limit)
|
||||
if errors.Is(err, io.EOF) {
|
||||
err = nil
|
||||
@@ -1226,8 +1227,9 @@ func (s *httpdServer) handleClientGetDirContents(w http.ResponseWriter, r *http.
|
||||
return nil, 0, err
|
||||
}
|
||||
results := make([]map[string]any, 0, len(contents))
|
||||
for _, info := range contents {
|
||||
for idx, info := range contents {
|
||||
res := make(map[string]any)
|
||||
res["id"] = offset + idx + 1
|
||||
res["url"] = getFileObjectURL(name, info.Name(), webClientFilesPath)
|
||||
if info.IsDir() {
|
||||
res["type"] = "1"
|
||||
|
||||
Reference in New Issue
Block a user