feat(alias): support load balance

This commit is contained in:
KirCute
2025-12-07 18:34:13 +08:00
parent 96cd714385
commit d9de036001
4 changed files with 406 additions and 272 deletions
+140 -240
View File
File diff suppressed because it is too large Load Diff
+4 -8
View File
@@ -10,11 +10,11 @@ type Addition struct {
// driver.RootPath
// define other
Paths string `json:"paths" required:"true" type:"text"`
ProtectSameName bool `json:"protect_same_name" default:"true" required:"false" help:"Protects same-name files from Delete or Rename"`
ParallelWrite bool `json:"parallel_write" type:"bool" default:"false"`
ReadConflictPolicy string `json:"read_conflict_policy" type:"select" options:"first,random" default:"random"`
WriteConflictPolicy string `json:"write_conflict_policy" type:"select" options:"disabled,first,deterministic,deterministic_or_all,all,all_strict" default:"disabled"`
PutConflictPolicy string `json:"put_conflict_policy" type:"select" options:"disabled,first,deterministic,deterministic_or_all,all,all_strict,random,quota,quota_strict" default:"disabled"`
DownloadConcurrency int `json:"download_concurrency" default:"0" required:"false" type:"number" help:"Need to enable proxy"`
DownloadPartSize int `json:"download_part_size" default:"0" type:"number" required:"false" help:"Need to enable proxy. Unit: KB"`
Writable bool `json:"writable" type:"bool" default:"false"`
ProviderPassThrough bool `json:"provider_pass_through" type:"bool" default:"false"`
DetailsPassThrough bool `json:"details_pass_through" type:"bool" default:"false"`
}
@@ -31,10 +31,6 @@ var config = driver.Config{
func init() {
op.RegisterDriver(func() driver.Driver {
return &Alias{
Addition: Addition{
ProtectSameName: true,
},
}
return &Alias{}
})
}
+43
View File
@@ -1 +1,44 @@
package alias
import (
"github.com/OpenListTeam/OpenList/v4/internal/model"
"github.com/pkg/errors"
)
const (
DisabledWP = "disabled"
FirstRWP = "first"
DeterministicWP = "deterministic"
DeterministicOrAllWP = "deterministic_or_all"
AllWP = "all"
AllStrictWP = "all_strict"
RandomBalancedRP = "random"
BalancedByQuotaP = "quota"
BalancedByQuotaStrictP = "quota_strict"
)
var (
ErrPathConflict = errors.New("path conflict")
ErrSamePathLeak = errors.New("leak some of same-name dirs")
ErrInvalidConflictPolicy = errors.New("invalid conflict policy")
ErrNoEnoughSpace = errors.New("none of same-name dirs has enough space")
)
type BalancedObj struct {
model.Obj
ExactReqPath string
}
func (b *BalancedObj) Unwrap() model.Obj {
return b.Obj
}
func GetExactReqPath(obj model.Obj) string {
if b, ok := obj.(*BalancedObj); ok {
return b.ExactReqPath
}
if unwrap, ok := obj.(model.ObjUnwrap); ok {
return GetExactReqPath(unwrap.Unwrap())
}
return ""
}
+219 -24
View File
File diff suppressed because it is too large Load Diff