Files tab: browser with breadcrumbs/sort/filter, text editor, image preview, streamed upload with progress, download, mkdir/touch/rename/move/chmod/delete, open-in-terminal; root toggle via sudo-reexecuted 'hamlab fs' helper

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Mitchell-Johnson
2026-09-18 05:39:57 -07:00
co-authored by Claude Fable 5.1
parent 38d4ee09ae
commit 63b020d556
9 changed files with 1094 additions and 9 deletions
+11 -2
View File
@@ -22,6 +22,7 @@ import (
"hamlab/internal/auth"
"hamlab/internal/config"
"hamlab/internal/cron"
"hamlab/internal/files"
"hamlab/internal/metrics"
"hamlab/internal/services"
"hamlab/internal/storage"
@@ -42,7 +43,7 @@ func main() {
}
cfgPath := flag.String("config", defaultCfg, "path to config.json")
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "usage: hamlab [-config path] [serve|passwd|version]\n")
fmt.Fprintf(os.Stderr, "usage: hamlab [-config path] [serve|passwd|version|fs …]\n")
flag.PrintDefaults()
}
flag.Parse()
@@ -51,6 +52,9 @@ func main() {
if flag.NArg() > 0 {
cmd = flag.Arg(0)
}
if cmd == "fs" { // privileged helper for the Files tab (run via sudo by the daemon)
os.Exit(files.Helper(flag.Args()[1:], os.Stdin, os.Stdout, os.Stderr))
}
cfg, err := config.Load(*cfgPath)
if err != nil {
log.Fatal(err)
@@ -151,7 +155,12 @@ func serve(cfg *config.Config) error {
tm := tasks.New()
up := updates.New(svc.Sudo(), tm)
sto := storage.New(svc.Sudo())
srv := api.New(cfg, sessions, mgr, col, st, svc, cr, tm, up, sto, web.FS(), version)
self, _ := os.Executable()
var sudoFS files.FS
if svc.Sudo() && self != "" {
sudoFS = files.Sudo{Self: self}
}
srv := api.New(cfg, sessions, mgr, col, st, svc, cr, tm, up, sto, files.Local{}, sudoFS, web.FS(), version)
hs := &http.Server{
Addr: cfg.Listen,
Handler: srv.Handler(),