Add file size and modified time to directory listings
This commit is contained in:
@@ -3,8 +3,9 @@ package protocol
|
||||
// Directory browsing for the chat folder picker. A client sends
|
||||
// Message{Type: ListDirectory, ID: <opaque>, ListDirectory: &DirectoryListRequest{Path: ...}}
|
||||
// and the server echoes the ID on a DirectoryListing reply. Listing is
|
||||
// restricted to the server user's home directory subtree, returns names and
|
||||
// kinds only (never file contents) and is bounded by DirectoryListingMaxEntries.
|
||||
// restricted to the server user's home directory subtree, returns names, kinds,
|
||||
// and file metadata (never file contents), and is bounded by
|
||||
// DirectoryListingMaxEntries.
|
||||
const (
|
||||
ListDirectory = "list_directory"
|
||||
DirectoryListing = "directory_listing"
|
||||
@@ -23,8 +24,8 @@ type DirectoryListRequest struct {
|
||||
// DirectoryListingResult is the directory_listing reply. Path is the absolute,
|
||||
// cleaned directory listed (expressed under Home), Parent is null at the home
|
||||
// root, and Entries are directories first, then files, each group sorted
|
||||
// case-insensitively. Files are listed by name only so a picker can show
|
||||
// context; they are not selectable.
|
||||
// case-insensitively. Entries include file size and modification time when
|
||||
// available; file contents are never returned, and files are not selectable.
|
||||
type DirectoryListingResult struct {
|
||||
Path string `json:"path"`
|
||||
Home string `json:"home"`
|
||||
@@ -35,11 +36,14 @@ type DirectoryListingResult struct {
|
||||
|
||||
// DirectoryEntry is one listed name. IsDir is true only for a directory (or a
|
||||
// symlink to one) that stays inside the home subtree; IsGitRepo marks a
|
||||
// directory containing .git; Hidden marks a dot-name.
|
||||
// directory containing .git; Hidden marks a dot-name. Size and Modified are
|
||||
// populated for files; directories have no file metadata.
|
||||
type DirectoryEntry struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
IsDir bool `json:"is_dir"`
|
||||
IsGitRepo bool `json:"is_git_repo"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Size int64 `json:"size,omitempty"`
|
||||
Modified string `json:"modified,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user