Skip to content

Commit

Permalink
fix(doge): the temporary access key is only valid for two hours (#6273)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
eryajf and xhofe authored Mar 27, 2024
1 parent cf08aa3 commit 8a18f47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/s3/doge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
14 changes: 14 additions & 0 deletions drivers/s3/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -28,6 +29,7 @@ type S3 struct {
linkClient *s3.S3

config driver.Config
cron *cron.Cron
}

func (d *S3) Config() driver.Config {
Expand All @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 8a18f47

Please sign in to comment.