mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-30 04:30:03 +08:00
Merge pull request #204 from Rain-kl/feat/save-strategy
新增功能: 重名文件时选择保存策略 - 重命名,覆盖,跳过
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package ctxkey
|
||||
|
||||
// ENUM(content-length)
|
||||
// ENUM(content-length, overwrite-existing)
|
||||
//
|
||||
//go:generate go-enum --values --names --flag --nocase --noprefix
|
||||
type ContextKey string
|
||||
|
||||
@@ -14,12 +14,15 @@ import (
|
||||
const (
|
||||
// ContentLength is a ContextKey of type content-length.
|
||||
ContentLength ContextKey = "content-length"
|
||||
// OverwriteExisting is a ContextKey of type overwrite-existing.
|
||||
OverwriteExisting ContextKey = "overwrite-existing"
|
||||
)
|
||||
|
||||
var ErrInvalidContextKey = fmt.Errorf("not a valid ContextKey, try [%s]", strings.Join(_ContextKeyNames, ", "))
|
||||
|
||||
var _ContextKeyNames = []string{
|
||||
string(ContentLength),
|
||||
string(OverwriteExisting),
|
||||
}
|
||||
|
||||
// ContextKeyNames returns a list of possible string values of ContextKey.
|
||||
@@ -33,6 +36,7 @@ func ContextKeyNames() []string {
|
||||
func ContextKeyValues() []ContextKey {
|
||||
return []ContextKey{
|
||||
ContentLength,
|
||||
OverwriteExisting,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +53,8 @@ func (x ContextKey) IsValid() bool {
|
||||
}
|
||||
|
||||
var _ContextKeyValue = map[string]ContextKey{
|
||||
"content-length": ContentLength,
|
||||
"content-length": ContentLength,
|
||||
"overwrite-existing": OverwriteExisting,
|
||||
}
|
||||
|
||||
// ParseContextKey attempts to convert a string to a ContextKey.
|
||||
|
||||
Reference in New Issue
Block a user