fix(storage): persist mover_warning_threshold in DB read/write

This commit is contained in:
2026-07-07 00:51:59 -04:00
parent 197b2ad13e
commit 24425b8b39
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
BINARY=nasctl BINARY=nasctl
VERSION?=0.7.4 VERSION?=0.7.5
GO?=go GO?=go
LDFLAGS=-s -w -X github.com/darroyo/nasctl/internal/web.Version=$(VERSION) -X github.com/darroyo/nasctl/internal/web.Commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) LDFLAGS=-s -w -X github.com/darroyo/nasctl/internal/web.Version=$(VERSION) -X github.com/darroyo/nasctl/internal/web.Commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_FLAGS=CGO_ENABLED=0 BUILD_FLAGS=CGO_ENABLED=0
+4 -3
View File
@@ -23,6 +23,7 @@ func scanStorageConfig(row interface {
&c.SnapraidDataDirs, &c.SnapraidDataDirs,
&c.SnapraidParityDir, &c.SnapraidParityDir,
&c.SnapraidScrubPlan, &c.SnapraidScrubPlan,
&c.MoverWarningThreshold,
&createdAt, &createdAt,
); err != nil { ); err != nil {
return StorageConfig{}, err return StorageConfig{}, err
@@ -35,7 +36,7 @@ func scanStorageConfig(row interface {
} }
func (d *DB) GetStorageConfig() (StorageConfig, error) { func (d *DB) GetStorageConfig() (StorageConfig, error) {
row := d.conn.QueryRow(`SELECT id, mover_source, mover_dest, mover_clean_macos, mover_remove_source, mover_inplace, mover_rsync_options, snapraid_content, snapraid_data_dirs, snapraid_parity_dir, snapraid_scrub_plan, updated_at FROM storage_config WHERE id = 1`) row := d.conn.QueryRow(`SELECT id, mover_source, mover_dest, mover_clean_macos, mover_remove_source, mover_inplace, mover_rsync_options, snapraid_content, snapraid_data_dirs, snapraid_parity_dir, snapraid_scrub_plan, mover_warning_threshold, updated_at FROM storage_config WHERE id = 1`)
c, err := scanStorageConfig(row) c, err := scanStorageConfig(row)
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return StorageConfig{ID: 1, MoverCleanMacOS: true, MoverRemoveSource: true, MoverInplace: true, SnapraidScrubPlan: 8}, nil return StorageConfig{ID: 1, MoverCleanMacOS: true, MoverRemoveSource: true, MoverInplace: true, SnapraidScrubPlan: 8}, nil
@@ -51,11 +52,11 @@ func (d *DB) UpdateStorageConfig(c StorageConfig) error {
UPDATE storage_config UPDATE storage_config
SET mover_source=?, mover_dest=?, mover_clean_macos=?, mover_remove_source=?, mover_inplace=?, SET mover_source=?, mover_dest=?, mover_clean_macos=?, mover_remove_source=?, mover_inplace=?,
mover_rsync_options=?, snapraid_content=?, snapraid_data_dirs=?, snapraid_parity_dir=?, mover_rsync_options=?, snapraid_content=?, snapraid_data_dirs=?, snapraid_parity_dir=?,
snapraid_scrub_plan=?, updated_at=datetime('now') snapraid_scrub_plan=?, mover_warning_threshold=?, updated_at=datetime('now')
WHERE id=1`, WHERE id=1`,
c.MoverSource, c.MoverDest, toInt(c.MoverCleanMacOS), toInt(c.MoverRemoveSource), toInt(c.MoverInplace), c.MoverSource, c.MoverDest, toInt(c.MoverCleanMacOS), toInt(c.MoverRemoveSource), toInt(c.MoverInplace),
c.MoverRsyncOptions, c.SnapraidContent, c.SnapraidDataDirs, c.SnapraidParityDir, c.MoverRsyncOptions, c.SnapraidContent, c.SnapraidDataDirs, c.SnapraidParityDir,
c.SnapraidScrubPlan, c.ID, c.SnapraidScrubPlan, c.MoverWarningThreshold, c.ID,
) )
if err != nil { if err != nil {
return fmt.Errorf("update storage config: %w", err) return fmt.Errorf("update storage config: %w", err)