Documentation
¶
Index ¶
- func Init() error
- func RegisterStorageFactory(storageType string, factory StorageConfigFactory)
- func ReloadConfig() error
- func Set(key string, value any)
- type AlistStorageConfig
- type Config
- func (c *Config) GetStorageByName(name string) StorageConfig
- func (c *Config) GetStorageNamesByUserID(userID int64) []string
- func (c *Config) GetStoragesByType(storageType types.StorageType) []StorageConfig
- func (c *Config) GetUsersID() []int64
- func (c *Config) HasStorage(userID int64, storageName string) bool
- type LocalStorageConfig
- type NewStorageConfig
- type StorageConfig
- type StorageConfigFactory
- type WebdavStorageConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterStorageFactory ¶ added in v0.11.0
func RegisterStorageFactory(storageType string, factory StorageConfigFactory)
func ReloadConfig ¶ added in v0.9.0
func ReloadConfig() error
Types ¶
type AlistStorageConfig ¶ added in v0.11.0
type AlistStorageConfig struct {
NewStorageConfig
URL string `toml:"url" mapstructure:"url" json:"url"`
Username string `toml:"username" mapstructure:"username" json:"username"`
Password string `toml:"password" mapstructure:"password" json:"password"`
Token string `toml:"token" mapstructure:"token" json:"token"`
BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
TokenExp int64 `toml:"token_exp" mapstructure:"token_exp" json:"token_exp"`
}
func (*AlistStorageConfig) GetName ¶ added in v0.11.0
func (a *AlistStorageConfig) GetName() string
func (*AlistStorageConfig) GetType ¶ added in v0.11.0
func (a *AlistStorageConfig) GetType() types.StorageType
func (*AlistStorageConfig) Validate ¶ added in v0.11.0
func (a *AlistStorageConfig) Validate() error
type Config ¶
type Config struct {
Workers int `toml:"workers" mapstructure:"workers"`
Retry int `toml:"retry" mapstructure:"retry"`
NoCleanCache bool `toml:"no_clean_cache" mapstructure:"no_clean_cache" json:"no_clean_cache"`
Users []userConfig `toml:"users" mapstructure:"users" json:"users"`
Temp tempConfig `toml:"temp" mapstructure:"temp"`
Log logConfig `toml:"log" mapstructure:"log"`
DB dbConfig `toml:"db" mapstructure:"db"`
Telegram telegramConfig `toml:"telegram" mapstructure:"telegram"`
Storages []StorageConfig `toml:"-" mapstructure:"-" json:"storages"`
// Deprecated
DeprecatedStorage deprecatedStorageConfig `toml:"storage" mapstructure:"storage"`
}
var Cfg *Config
func (*Config) GetStorageByName ¶ added in v0.11.0
func (c *Config) GetStorageByName(name string) StorageConfig
func (*Config) GetStorageNamesByUserID ¶ added in v0.11.0
func (*Config) GetStoragesByType ¶ added in v0.11.0
func (c *Config) GetStoragesByType(storageType types.StorageType) []StorageConfig
func (*Config) GetUsersID ¶ added in v0.11.0
type LocalStorageConfig ¶ added in v0.11.0
type LocalStorageConfig struct {
NewStorageConfig
BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
}
func (*LocalStorageConfig) GetName ¶ added in v0.11.0
func (l *LocalStorageConfig) GetName() string
func (*LocalStorageConfig) GetType ¶ added in v0.11.0
func (l *LocalStorageConfig) GetType() types.StorageType
func (*LocalStorageConfig) Validate ¶ added in v0.11.0
func (l *LocalStorageConfig) Validate() error
type NewStorageConfig ¶ added in v0.11.0
type NewStorageConfig struct {
Name string `toml:"name" mapstructure:"name" json:"name"`
Type string `toml:"type" mapstructure:"type" json:"type"`
Enable bool `toml:"enable" mapstructure:"enable" json:"enable"`
RawConfig map[string]interface{} `toml:"-" mapstructure:",remain"`
}
Base storage config
type StorageConfig ¶ added in v0.11.0
type StorageConfig interface {
Validate() error
GetType() types.StorageType
GetName() string
}
func LoadStorageConfigs ¶ added in v0.11.0
func LoadStorageConfigs(v *viper.Viper) ([]StorageConfig, error)
type StorageConfigFactory ¶ added in v0.11.0
type StorageConfigFactory func(cfg *NewStorageConfig) (StorageConfig, error)
type WebdavStorageConfig ¶ added in v0.11.0
type WebdavStorageConfig struct {
NewStorageConfig
URL string `toml:"url" mapstructure:"url" json:"url"`
Username string `toml:"username" mapstructure:"username" json:"username"`
Password string `toml:"password" mapstructure:"password" json:"password"`
BasePath string `toml:"base_path" mapstructure:"base_path" json:"base_path"`
}
func (*WebdavStorageConfig) GetName ¶ added in v0.11.0
func (w *WebdavStorageConfig) GetName() string
func (*WebdavStorageConfig) GetType ¶ added in v0.11.0
func (w *WebdavStorageConfig) GetType() types.StorageType
func (*WebdavStorageConfig) Validate ¶ added in v0.11.0
func (w *WebdavStorageConfig) Validate() error
Click to show internal directories.
Click to hide internal directories.