mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-08-08 14:03:25 +08:00
feat: 添加块大小配置项
This commit is contained in:
@@ -8,8 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Threads int `toml:"threads" mapstructure:"threads"`
|
Threads int `toml:"threads" mapstructure:"threads"`
|
||||||
Workers int `toml:"workers" mapstructure:"workers"`
|
Workers int `toml:"workers" mapstructure:"workers"`
|
||||||
|
ChunkSize int32 `toml:"chunk_size" mapstructure:"chunk_size"`
|
||||||
|
|
||||||
Temp tempConfig `toml:"temp" mapstructure:"temp"`
|
Temp tempConfig `toml:"temp" mapstructure:"temp"`
|
||||||
Log logConfig `toml:"log" mapstructure:"log"`
|
Log logConfig `toml:"log" mapstructure:"log"`
|
||||||
@@ -77,6 +78,7 @@ func Init() {
|
|||||||
|
|
||||||
viper.SetDefault("threads", 3)
|
viper.SetDefault("threads", 3)
|
||||||
viper.SetDefault("workers", 3)
|
viper.SetDefault("workers", 3)
|
||||||
|
viper.SetDefault("chunk_size", 50*1024*1024)
|
||||||
|
|
||||||
viper.SetDefault("temp.base_path", "cache/")
|
viper.SetDefault("temp.base_path", "cache/")
|
||||||
viper.SetDefault("temp.cache_ttl", 3600)
|
viper.SetDefault("temp.cache_ttl", 3600)
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ func processPendingTask(task types.Task) error {
|
|||||||
logger.L.Debugf("Start downloading file: %s", task.FileName)
|
logger.L.Debugf("Start downloading file: %s", task.FileName)
|
||||||
bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "正在下载文件...")
|
bot.Client.EditMessage(task.ChatID, task.ReplyMessageID, "正在下载文件...")
|
||||||
dest, err := message.Download(&telegram.DownloadOptions{
|
dest, err := message.Download(&telegram.DownloadOptions{
|
||||||
FileName: common.GetCacheFilePath(task.FileName),
|
FileName: common.GetCacheFilePath(task.FileName),
|
||||||
Threads: config.Cfg.Threads,
|
Threads: config.Cfg.Threads,
|
||||||
|
ChunkSize: config.Cfg.ChunkSize,
|
||||||
// ProgressCallback: func(totalBytes, downloadedBytes int64) {},
|
// ProgressCallback: func(totalBytes, downloadedBytes int64) {},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user