Add file size and modified time to directory listings

This commit is contained in:
2026-11-07 00:54:36 +00:00
parent 0ea249be36
commit c4ccbb3f95
4 changed files with 51 additions and 7 deletions
+9 -2
View File
@@ -8,6 +8,7 @@ import (
"path/filepath"
"sort"
"strings"
"time"
"git.a-wan.net/alan/pipelines/internal/protocol"
)
@@ -131,8 +132,8 @@ func describePathError(path string, err error) error {
}
// readDirectoryEntries reads at most directoryListingScanLimit names, sorts
// directories first then case-insensitively, and caps the result. Only names
// and kinds are read; no file is opened.
// directories first then case-insensitively, and caps the result. No file is
// opened.
func readDirectoryEntries(realHome, realDir, shown string, maxEntries int) ([]protocol.DirectoryEntry, bool, error) {
dir, err := os.Open(realDir)
if err != nil {
@@ -191,6 +192,12 @@ func describeEntry(realHome, realDir, shown string, item fs.DirEntry) protocol.D
entry.IsDir = true
}
}
if !entry.IsDir {
if info, err := item.Info(); err == nil {
entry.Size = info.Size()
entry.Modified = info.ModTime().UTC().Format(time.RFC3339)
}
}
if entry.IsDir {
if _, err := os.Lstat(filepath.Join(full, ".git")); err == nil {
entry.IsGitRepo = true