From b054919d5cd54f7d2fc37ec4c06b1237947d49d9 Mon Sep 17 00:00:00 2001 From: MadDogOwner Date: Tue, 19 Aug 2025 19:19:44 +0800 Subject: [PATCH] feat(ilanzou): add support for rapid upload and fix duplication handling (#1065) * feat(ilanzou): add support for rapid upload token handling * feat(ilanzou): add NoOverwriteUpload option --- drivers/ilanzou/driver.go | 17 +++++++++++++++++ drivers/ilanzou/meta.go | 14 ++++++++------ drivers/ilanzou/types.go | 12 ++++++++++++ 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/ilanzou/driver.go b/drivers/ilanzou/driver.go index 0e4f9be2..881c59ed 100644 --- a/drivers/ilanzou/driver.go +++ b/drivers/ilanzou/driver.go @@ -296,6 +296,23 @@ func (d *ILanZou) Put(ctx context.Context, dstDir model.Obj, s model.FileStreame return nil, err } upToken := utils.Json.Get(res, "upToken").ToString() + if upToken == "-1" { + // 支持秒传 + var resp UploadTokenRapidResp + err := utils.Json.Unmarshal(res, &resp) + if err != nil { + return nil, err + } + return &model.Object{ + ID: strconv.FormatInt(resp.Map.FileID, 10), + Name: resp.Map.FileName, + Size: s.GetSize(), + Modified: s.ModTime(), + Ctime: s.CreateTime(), + IsFolder: false, + HashInfo: utils.NewHashInfo(utils.MD5, etag), + }, nil + } now := time.Now() key := fmt.Sprintf("disk/%d/%d/%d/%s/%016d", now.Year(), now.Month(), now.Day(), d.account, now.UnixMilli()) reader := driver.NewLimitedUploadStream(ctx, &driver.ReaderUpdatingProgress{ diff --git a/drivers/ilanzou/meta.go b/drivers/ilanzou/meta.go index 9cddcb20..5b38f1c2 100644 --- a/drivers/ilanzou/meta.go +++ b/drivers/ilanzou/meta.go @@ -29,9 +29,10 @@ func init() { op.RegisterDriver(func() driver.Driver { return &ILanZou{ config: driver.Config{ - Name: "ILanZou", - DefaultRoot: "0", - LocalSort: true, + Name: "ILanZou", + DefaultRoot: "0", + LocalSort: true, + NoOverwriteUpload: true, }, conf: Conf{ base: "https://api.ilanzou.com", @@ -47,9 +48,10 @@ func init() { op.RegisterDriver(func() driver.Driver { return &ILanZou{ config: driver.Config{ - Name: "FeijiPan", - DefaultRoot: "0", - LocalSort: true, + Name: "FeijiPan", + DefaultRoot: "0", + LocalSort: true, + NoOverwriteUpload: true, }, conf: Conf{ base: "https://api.feijipan.com", diff --git a/drivers/ilanzou/types.go b/drivers/ilanzou/types.go index 135724c7..04579c36 100644 --- a/drivers/ilanzou/types.go +++ b/drivers/ilanzou/types.go @@ -43,6 +43,18 @@ type Part struct { ETag string `json:"etag"` } +type UploadTokenRapidResp struct { + Msg string `json:"msg"` + Code int `json:"code"` + UpToken string `json:"upToken"` + Map struct { + FileIconID int `json:"fileIconId"` + FileName string `json:"fileName"` + FileIcon string `json:"fileIcon"` + FileID int64 `json:"fileId"` + } `json:"map"` +} + type UploadResultResp struct { Msg string `json:"msg"` Code int `json:"code"`