mirror of https://github.com/Xhofe/alist
fix(doge): the temporary access key is only valid for two hours (#6273)
* feat: add doge driver * doc: 补充readme文档 * fix: 对齐meta信息 * fix: 调整结构体名字,与driver保持一致 * perf: merge to s3 * Rename goge.go to doge.go * fix: 解决多吉云临时秘钥两个小时过期的问题 * fix: 定时任务在Drop中Stop --------- Co-authored-by: Andy Hsu <i@nn.ci>pull/6277/head
parent
cf08aa3668
commit
8a18f47e68
|
@ -17,6 +17,7 @@ type TmpTokenResponse struct {
|
|||
}
|
||||
type TmpTokenResponseData struct {
|
||||
Credentials Credentials `json:"Credentials"`
|
||||
ExpiredAt int `json:"ExpiredAt"`
|
||||
}
|
||||
type Credentials struct {
|
||||
AccessKeyId string `json:"accessKeyId,omitempty"`
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/stream"
|
||||
"github.com/alist-org/alist/v3/pkg/cron"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/driver"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
|
@ -28,6 +29,7 @@ type S3 struct {
|
|||
linkClient *s3.S3
|
||||
|
||||
config driver.Config
|
||||
cron *cron.Cron
|
||||
}
|
||||
|
||||
func (d *S3) Config() driver.Config {
|
||||
|
@ -42,6 +44,15 @@ func (d *S3) Init(ctx context.Context) error {
|
|||
if d.Region == "" {
|
||||
d.Region = "alist"
|
||||
}
|
||||
if d.config.Name == "Doge" {
|
||||
d.cron = cron.NewCron(time.Minute * 118)
|
||||
d.cron.Do(func() {
|
||||
err := d.initSession()
|
||||
if err != nil {
|
||||
log.Errorln("Doge init session error:", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
err := d.initSession()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -52,6 +63,9 @@ func (d *S3) Init(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (d *S3) Drop(ctx context.Context) error {
|
||||
if d.cron != nil {
|
||||
d.cron.Stop()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue