feat(storage): rename snapraid_content to snapraid_conf; clarify conf vs content file; add auto-detect and conf viewer
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
-- Rename snapraid_content to snapraid_conf to reflect that this field
|
||||
-- holds the path to the snapraid.conf TEXT configuration file,
|
||||
-- not the binary snapraid.content database file.
|
||||
ALTER TABLE storage_config RENAME COLUMN snapraid_content TO snapraid_conf;
|
||||
@@ -97,7 +97,7 @@ type StorageConfig struct {
|
||||
MoverInplace bool `json:"mover_inplace"`
|
||||
MoverRsyncOptions string `json:"mover_rsync_options"`
|
||||
MoverWarningThreshold int `json:"mover_warning_threshold"`
|
||||
SnapraidContent string `json:"snapraid_content"`
|
||||
SnapraidConf string `json:"snapraid_conf"`
|
||||
SnapraidDataDirs string `json:"snapraid_data_dirs"`
|
||||
SnapraidParityDir string `json:"snapraid_parity_dir"`
|
||||
SnapraidScrubPlan int `json:"snapraid_scrub_plan"`
|
||||
|
||||
@@ -19,7 +19,7 @@ func scanStorageConfig(row interface {
|
||||
&removeSource,
|
||||
&inplace,
|
||||
&c.MoverRsyncOptions,
|
||||
&c.SnapraidContent,
|
||||
&c.SnapraidConf,
|
||||
&c.SnapraidDataDirs,
|
||||
&c.SnapraidParityDir,
|
||||
&c.SnapraidScrubPlan,
|
||||
@@ -36,7 +36,7 @@ func scanStorageConfig(row interface {
|
||||
}
|
||||
|
||||
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, mover_warning_threshold, 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_conf, snapraid_data_dirs, snapraid_parity_dir, snapraid_scrub_plan, mover_warning_threshold, updated_at FROM storage_config WHERE id = 1`)
|
||||
c, err := scanStorageConfig(row)
|
||||
if err == sql.ErrNoRows {
|
||||
return StorageConfig{ID: 1, MoverCleanMacOS: true, MoverRemoveSource: true, MoverInplace: true, SnapraidScrubPlan: 8}, nil
|
||||
@@ -51,11 +51,11 @@ func (d *DB) UpdateStorageConfig(c StorageConfig) error {
|
||||
_, err := d.conn.Exec(`
|
||||
UPDATE storage_config
|
||||
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_conf=?, snapraid_data_dirs=?, snapraid_parity_dir=?,
|
||||
snapraid_scrub_plan=?, mover_warning_threshold=?, updated_at=datetime('now')
|
||||
WHERE id=1`,
|
||||
c.MoverSource, c.MoverDest, toInt(c.MoverCleanMacOS), toInt(c.MoverRemoveSource), toInt(c.MoverInplace),
|
||||
c.MoverRsyncOptions, c.SnapraidContent, c.SnapraidDataDirs, c.SnapraidParityDir,
|
||||
c.MoverRsyncOptions, c.SnapraidConf, c.SnapraidDataDirs, c.SnapraidParityDir,
|
||||
c.SnapraidScrubPlan, c.MoverWarningThreshold, c.ID,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user