* refactor: a big refactor. wip * refactor: port handle file * refactor: place all handlers * fix: task info nil pointer * feat: enhance task progress tracking and context management * feat: cancel task * feat: stream mode * feat: silent mode * feat: dir cmd * refactor: remove unused old file * feat: rule cmd * feat: handle silent mode * feat: batch task * fix: batch task progress and temp file cleanup * refactor: update file creation and cleanup methods for better resource management * feat: add save command with silent mode handling * feat: message link * feat: update message prompts to include file count in storage selection * feat: slient save links * refactor: reduce dup code * feat: rule type * feat: chose dir * feat: refactor file handling and storage rules, improve error handling and logging * feat: rule mode * feat: telegraph pics * fix: tphpics nil pointer and inaccurate dirpath * feat: silent save telegraph * feat: add suffix to avoid file overwrite * feat: new storage telegram * chore: tidy go mod
37 lines
943 B
Go
37 lines
943 B
Go
package storage
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
storenum "github.com/krau/SaveAny-Bot/pkg/enums/storage"
|
|
)
|
|
|
|
type WebdavStorageConfig struct {
|
|
BaseConfig
|
|
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 (w *WebdavStorageConfig) Validate() error {
|
|
if w.URL == "" {
|
|
return fmt.Errorf("url is required for webdav storage")
|
|
}
|
|
if w.Username == "" || w.Password == "" {
|
|
return fmt.Errorf("username and password is required for webdav storage")
|
|
}
|
|
if w.BasePath == "" {
|
|
return fmt.Errorf("base_path is required for webdav storage")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (w *WebdavStorageConfig) GetType() storenum.StorageType {
|
|
return storenum.Webdav
|
|
}
|
|
|
|
func (w *WebdavStorageConfig) GetName() string {
|
|
return w.Name
|
|
}
|