From abd91a9080be0b68b049bcd4bdf25ba6ae16f95d Mon Sep 17 00:00:00 2001 From: tanlang Date: Fri, 28 Jul 2023 14:49:38 +0800 Subject: [PATCH] feat: add name to storage.json --- damocles-manager/modules/config.go | 9 +++++++-- ...\215\347\275\256\350\247\243\346\236\220.md" | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/damocles-manager/modules/config.go b/damocles-manager/modules/config.go index e78ca1c21..cf1afb5dd 100644 --- a/damocles-manager/modules/config.go +++ b/damocles-manager/modules/config.go @@ -177,6 +177,7 @@ type StoragePathConfig struct { } type LocalPath struct { + Name string Path string } @@ -288,7 +289,7 @@ func (c CommonConfig) GetPersistStores() []PersistStoreConfig { log.Errorf("decode storage config file %s failed: %s", p, err) } else { for _, lp := range cfg.StoragePaths { - ret = append(ret, PersistStoreConfig{ + psc := PersistStoreConfig{ Config: objstore.Config{ Path: lp.Path, Meta: preset.Meta, @@ -300,7 +301,11 @@ func (c CommonConfig) GetPersistStores() []PersistStoreConfig { AllowMiners: preset.AllowMiners, DenyMiners: preset.DenyMiners, }, - }) + } + if lp.Name != "" { + psc.Name = lp.Name + } + ret = append(ret, psc) } log.Infof("load storage config file %s success", p) } diff --git "a/docs/zh/04.damocles-manager\347\232\204\351\205\215\347\275\256\350\247\243\346\236\220.md" "b/docs/zh/04.damocles-manager\347\232\204\351\205\215\347\275\256\350\247\243\346\236\220.md" index d6150934f..82f554c23 100644 --- "a/docs/zh/04.damocles-manager\347\232\204\351\205\215\347\275\256\350\247\243\346\236\220.md" +++ "b/docs/zh/04.damocles-manager\347\232\204\351\205\215\347\275\256\350\247\243\346\236\220.md" @@ -252,7 +252,7 @@ Path = "/mnt/mass/piece1" #### 基础配置范例 ```toml -[[Common.PersistStores]] +[Common.PieceStorePreset] # 只读,选填项,布尔类型 # 默认值为 false @@ -302,6 +302,21 @@ StorageConfigPath = "/optional/path/to/your/storage.json" # ``` +- storage.json + +```json +{ + "StoragePaths": [ + { + "Name": "persist", + "Path": "/root/persist" + } + ] +} +``` + +其中 `Name` 属性可以省略,省略时默认使用 `Path` 属性的值作为 `Name`。 + ### [[Common.PersistStores]] `Common.PersistStores` 用于配置扇区持久化数据存储。与之对应的是 `damocles-worker` 中的 `attached` 概念。