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
二丫讲梵 2024-03-27 14:22:26 +08:00 committed by GitHub
parent cf08aa3668
commit 8a18f47e68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View File

@ -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"`

View File

@ -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
}