mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-25 10:10:24 +08:00
refactor: replace key package with ctxkey for context keys
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
config "github.com/krau/SaveAny-Bot/config/storage"
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/key"
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/ctxkey"
|
||||
storenum "github.com/krau/SaveAny-Bot/pkg/enums/storage"
|
||||
)
|
||||
|
||||
@@ -118,7 +118,7 @@ func (a *Alist) Save(ctx context.Context, reader io.Reader, storagePath string)
|
||||
req.Header.Set("Authorization", a.token)
|
||||
req.Header.Set("File-Path", url.PathEscape(candidate))
|
||||
req.Header.Set("Content-Type", "application/octet-stream")
|
||||
if length := ctx.Value(key.ContextKeyContentLength); length != nil {
|
||||
if length := ctx.Value(ctxkey.ContentLength); length != nil {
|
||||
length, ok := length.(int64)
|
||||
if ok {
|
||||
req.ContentLength = length
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
config "github.com/krau/SaveAny-Bot/config/storage"
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/key"
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/ctxkey"
|
||||
storenum "github.com/krau/SaveAny-Bot/pkg/enums/storage"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
@@ -74,7 +74,7 @@ func (m *Minio) Save(ctx context.Context, r io.Reader, storagePath string) error
|
||||
candidate = fmt.Sprintf("%s_%d%s", base, i, ext)
|
||||
}
|
||||
size := int64(-1)
|
||||
if length := ctx.Value(key.ContextKeyContentLength); length != nil {
|
||||
if length := ctx.Value(ctxkey.ContentLength); length != nil {
|
||||
length, ok := length.(int64)
|
||||
if ok && length > 0 {
|
||||
size = length
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/key"
|
||||
"github.com/krau/SaveAny-Bot/pkg/enums/ctxkey"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
@@ -54,7 +54,7 @@ func (c *Client) doRequest(ctx context.Context, method WebdavMethod, url string,
|
||||
req.Header.Set("Depth", "1")
|
||||
}
|
||||
if method == WebdavMethodPut && ctx != nil {
|
||||
if length := ctx.Value(key.ContextKeyContentLength); length != nil {
|
||||
if length := ctx.Value(ctxkey.ContentLength); length != nil {
|
||||
if l, ok := length.(int64); ok {
|
||||
req.ContentLength = l
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user