mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2026-10-19 16:14:39 +00:00
feature (metadata): dedicated metadata field in ls
This commit is contained in:
@@ -120,12 +120,13 @@ type WorkflowSpecs struct {
|
||||
}
|
||||
|
||||
type File struct {
|
||||
FName string `json:"name"`
|
||||
FType string `json:"type"`
|
||||
FTime int64 `json:"time"`
|
||||
FSize int64 `json:"size"`
|
||||
FPath string `json:"path,omitempty"`
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
FName string `json:"name"`
|
||||
FType string `json:"type"`
|
||||
FTime int64 `json:"time"`
|
||||
FSize int64 `json:"size"`
|
||||
FPath string `json:"path,omitempty"`
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
func (f File) Name() string {
|
||||
|
||||
@@ -14,6 +14,15 @@ import (
|
||||
"github.com/mickael-kerjean/filestash/server/pkg/permissions"
|
||||
)
|
||||
|
||||
type FileInfo struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Size int64 `json:"size"`
|
||||
Time int64 `json:"time"`
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
Metadata map[string]any `json:"metadata,omitempty"`
|
||||
}
|
||||
|
||||
func FileLs(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
if permissions.CanRead(ctx) == false {
|
||||
if permissions.CanUpload(ctx) == false {
|
||||
@@ -110,12 +119,10 @@ func FileLs(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
return "directory"
|
||||
}(entries[i].Mode()),
|
||||
Mode: func(mode os.FileMode) uint32 {
|
||||
return uint32(mode)
|
||||
}(entries[i].Mode()),
|
||||
}
|
||||
if f, ok := entries[i].Sys().(File); ok && f.Offline == true {
|
||||
files[i].Offline = true
|
||||
if f, ok := entries[i].Sys().(File); ok {
|
||||
files[i].Offline = f.Offline
|
||||
files[i].Metadata = f.Metadata
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package files
|
||||
|
||||
type FileInfo struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Size int64 `json:"size"`
|
||||
Time int64 `json:"time"`
|
||||
Mode uint32 `json:"mode,omitempty"`
|
||||
Offline bool `json:"offline,omitempty"`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package plg_backend_nfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -265,6 +266,13 @@ func (this NfsShare) Ls(path string) ([]os.FileInfo, error) {
|
||||
}(),
|
||||
FSize: int64(dir.Attr.Attr.Filesize),
|
||||
FTime: int64(dir.Attr.Attr.Ctime.Seconds),
|
||||
Metadata: map[string]any{
|
||||
"uid": dir.Attr.Attr.UID,
|
||||
"gid": dir.Attr.Attr.GID,
|
||||
"mode": fmt.Sprintf("%#o", dir.Attr.Attr.FileMode),
|
||||
"atime": int64(dir.Attr.Attr.Atime.Seconds) * 1000,
|
||||
"mtime": int64(dir.Attr.Attr.Mtime.Seconds) * 1000,
|
||||
},
|
||||
})
|
||||
}
|
||||
return files, nil
|
||||
|
||||
Reference in New Issue
Block a user