mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-12 02:29:42 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ef7c5ce60 | ||
|
|
03c833acbf |
@@ -2,6 +2,7 @@ package common
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/imroc/req/v3"
|
"github.com/imroc/req/v3"
|
||||||
"github.com/krau/SaveAny-Bot/config"
|
"github.com/krau/SaveAny-Bot/config"
|
||||||
@@ -10,7 +11,7 @@ import (
|
|||||||
var ReqClient *req.Client
|
var ReqClient *req.Client
|
||||||
|
|
||||||
func initClient() {
|
func initClient() {
|
||||||
ReqClient = req.NewClient().SetOutputDirectory(config.Cfg.Temp.BasePath)
|
ReqClient = req.NewClient().SetOutputDirectory(config.Cfg.Temp.BasePath).SetTimeout(86400 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDownloadedFilePath(filename string) string {
|
func GetDownloadedFilePath(filename string) string {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func refreshToken(client *req.Client) {
|
|||||||
func (a *Alist) Init() {
|
func (a *Alist) Init() {
|
||||||
basePath = config.Cfg.Storage.Alist.BasePath
|
basePath = config.Cfg.Storage.Alist.BasePath
|
||||||
baseUrl = config.Cfg.Storage.Alist.URL
|
baseUrl = config.Cfg.Storage.Alist.URL
|
||||||
reqClient = req.C().SetTLSHandshakeTimeout(time.Second * 10).SetBaseURL(baseUrl)
|
reqClient = req.C().SetTLSHandshakeTimeout(time.Second * 10).SetBaseURL(baseUrl).SetTimeout(time.Hour * 24)
|
||||||
loginReq = &loginRequset{
|
loginReq = &loginRequset{
|
||||||
Username: config.Cfg.Storage.Alist.Username,
|
Username: config.Cfg.Storage.Alist.Username,
|
||||||
Password: config.Cfg.Storage.Alist.Password,
|
Password: config.Cfg.Storage.Alist.Password,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/krau/SaveAny-Bot/config"
|
"github.com/krau/SaveAny-Bot/config"
|
||||||
"github.com/krau/SaveAny-Bot/logger"
|
"github.com/krau/SaveAny-Bot/logger"
|
||||||
@@ -27,6 +28,7 @@ func (w *Webdav) Init() {
|
|||||||
logger.L.Fatalf("Failed to connect to webdav server: %v", err)
|
logger.L.Fatalf("Failed to connect to webdav server: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
Client.SetTimeout(24 * time.Hour)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webdav) Save(ctx context.Context, filePath, storagePath string) error {
|
func (w *Webdav) Save(ctx context.Context, filePath, storagePath string) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user