27a52d2986
New 'Almacenamiento' page with:
- Auto-detection of rsync, mergerfs, snapraid binaries and mergerfs mount
- Configurable pool settings (source/dest, macOS cleanup, rsync flags)
- Mergerfs mover with dry-run preview and live SSE output streaming
- SnapRAID diff/sync/scrub/check with live SSE output
- Async job system (1 concurrent job) with SSE streaming
- Job history table
Backend:
- internal/storage/ package with capabilities, mergerfs, snapraid, jobs
- storage_config and storage_jobs DB tables (migration 0008)
- GET/PUT /api/storage/config, GET /api/storage/capabilities
- POST/GET /api/storage/jobs, GET /api/storage/jobs/{id}/stream
- Storage operations disabled when NASCTL_EXEC_SYSTEM=false
Closes #new-feature
35 lines
929 B
Go
35 lines
929 B
Go
package storage
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/darroyo/nasctl/internal/db"
|
|
"github.com/darroyo/nasctl/internal/system"
|
|
)
|
|
|
|
type Capabilities struct {
|
|
Rsync bool `json:"rsync"`
|
|
MergerfsBin bool `json:"mergerfs"`
|
|
MergerfsMounted bool `json:"mergerfs_mounted"`
|
|
SnapraidBin bool `json:"snapraid"`
|
|
}
|
|
|
|
func Probe(ctx context.Context) (Capabilities, error) {
|
|
rsyncOut, _, _ := system.Run(ctx, "command", "-v", "rsync")
|
|
snapraidOut, _, _ := system.Run(ctx, "command", "-v", "snapraid")
|
|
mergerfsOut, _, _ := system.Run(ctx, "command", "-v", "mergerfs")
|
|
|
|
_, _, mergerfsMountedErr := system.Run(ctx, "grep", "-q", "fuse.mergerfs", "/proc/mounts")
|
|
|
|
return Capabilities{
|
|
Rsync: len(rsyncOut) > 0,
|
|
MergerfsBin: len(mergerfsOut) > 0,
|
|
MergerfsMounted: mergerfsMountedErr == nil,
|
|
SnapraidBin: len(snapraidOut) > 0,
|
|
}, nil
|
|
}
|
|
|
|
func ValidatePaths(cfg db.StorageConfig) error {
|
|
return nil
|
|
}
|