feat: file manager with browse, search, upload, chmod/chown
- Full file browser page at /files with lazy-load, breadcrumbs, drag&drop - FileBrowserModal component for path selection from Samba/NFS forms - PathField component replaces bare inputs in share/export forms - Backend: /api/files/* routes with List, Mkdir, Rename, Delete, Chmod, Chown, Upload, Download, Preview, Search - Reuses NASCTL_ALLOWED_ROOTS for path validation - NASCTL_UPLOAD_MAX_BYTES (100MB) and NASCTL_PREVIEW_MAX_BYTES (256KB) env vars - Capabilities endpoint returns chmod/chown availability (requires root) - Version bump: 0.3.2 -> 0.4.0
This commit is contained in:
+18
-4
@@ -6,6 +6,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/darroyo/nasctl/internal/db"
|
||||
@@ -27,6 +28,8 @@ func main() {
|
||||
adminUser := flag.String("admin-user", envOrDefault("NASCTL_ADMIN_USER", "admin"), "Initial admin username (only used if no admin exists)")
|
||||
adminPass := flag.String("admin-pass", envOrDefault("NASCTL_ADMIN_PASSWORD", "admin"), "Initial admin password (only used if no admin exists)")
|
||||
importOnBoot := flag.Bool("import-on-boot", envOrDefault("NASCTL_IMPORT_ON_BOOT", "false") == "true", "Import existing smb.conf and /etc/exports on first boot")
|
||||
uploadMaxBytes := flag.Int64("upload-max-bytes", parseEnvInt64("NASCTL_UPLOAD_MAX_BYTES", 104857600), "Max bytes for file uploads")
|
||||
previewMaxBytes := flag.Int64("preview-max-bytes", parseEnvInt64("NASCTL_PREVIEW_MAX_BYTES", 262144), "Max bytes for file previews")
|
||||
flag.Parse()
|
||||
|
||||
if err := os.MkdirAll(filepath.Dir(*dbPath), 0o755); err != nil {
|
||||
@@ -80,10 +83,12 @@ func main() {
|
||||
|
||||
eng := engine.New(sambaModule, nfsModule, usersModule)
|
||||
srv := web.NewServer(database, eng, web.Options{
|
||||
AllowedRoots: parseRoots(*allowedRoots),
|
||||
Auth: auth,
|
||||
SMBConfPath: *smbConfPath,
|
||||
ExportsPath: *exportsPath,
|
||||
AllowedRoots: parseRoots(*allowedRoots),
|
||||
Auth: auth,
|
||||
SMBConfPath: *smbConfPath,
|
||||
ExportsPath: *exportsPath,
|
||||
UploadMaxBytes: *uploadMaxBytes,
|
||||
PreviewMaxBytes: *previewMaxBytes,
|
||||
})
|
||||
|
||||
log.Printf("nasctl %s (commit %s) listening on %s (db=%s exec-system=%v)", web.Version, web.Commit, *addr, *dbPath, *execSystem)
|
||||
@@ -113,3 +118,12 @@ func envOrDefault(key, fallback string) string {
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func parseEnvInt64(key string, fallback int64) int64 {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
if v, err := strconv.ParseInt(value, 10, 64); err == nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user