From bfd2340732f90b9b56382aa684be86506ed9ad60 Mon Sep 17 00:00:00 2001 From: GuerraMorgan <35589850+GuerraMorgan@users.noreply.github.com> Date: Wed, 12 Aug 2020 20:31:28 +0800 Subject: [PATCH 01/34] Add: Unix Socket support (#466) * Update conf.go * Update driver.go * Update session.go * Update defaults.go * Update main.go * Update conf.go * Update defaults.go --- main.go | 10 ++++++++++ middleware/session.go | 2 +- pkg/cache/driver.go | 2 +- pkg/conf/conf.go | 6 ++++++ pkg/conf/defaults.go | 5 +++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index de6bce0..558a66a 100644 --- a/main.go +++ b/main.go @@ -40,6 +40,16 @@ func main() { }() } + // 如果启用了Unix + if conf.UnixConfig.Listen != "" { + go func() { + util.Log().Info("开始监听 %s", conf.UnixConfig.Listen) + if err := api.RunUnix(conf.UnixConfig.Listen); err != nil { + util.Log().Error("无法监听[%s],%s", conf.UnixConfig.Listen, err) + } + }() + } + util.Log().Info("开始监听 %s", conf.SystemConfig.Listen) if err := api.Run(conf.SystemConfig.Listen); err != nil { util.Log().Error("无法监听[%s],%s", conf.SystemConfig.Listen, err) diff --git a/middleware/session.go b/middleware/session.go index 06b56e5..f89609d 100644 --- a/middleware/session.go +++ b/middleware/session.go @@ -18,7 +18,7 @@ func Session(secret string) gin.HandlerFunc { // Redis设置不为空,且非测试模式时使用Redis if conf.RedisConfig.Server != "" && gin.Mode() != gin.TestMode { var err error - Store, err = redis.NewStoreWithDB(10, "tcp", conf.RedisConfig.Server, conf.RedisConfig.Password, conf.RedisConfig.DB, []byte(secret)) + Store, err = redis.NewStoreWithDB(10, conf.RedisConfig.Network, conf.RedisConfig.Server, conf.RedisConfig.Password, conf.RedisConfig.DB, []byte(secret)) if err != nil { util.Log().Panic("无法连接到 Redis:%s", err) } diff --git a/pkg/cache/driver.go b/pkg/cache/driver.go index 0226531..07d7152 100644 --- a/pkg/cache/driver.go +++ b/pkg/cache/driver.go @@ -15,7 +15,7 @@ func Init() { if conf.RedisConfig.Server != "" && gin.Mode() != gin.TestMode { Store = NewRedisStore( 10, - "tcp", + conf.RedisConfig.Network, conf.RedisConfig.Server, conf.RedisConfig.Password, conf.RedisConfig.DB, diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index a19110b..43f2481 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -33,6 +33,10 @@ type ssl struct { Listen string `validate:"required"` } +type unix struct { + Listen string +} + // slave 作为slave存储端配置 type slave struct { Secret string `validate:"omitempty,gte=64"` @@ -57,6 +61,7 @@ type captcha struct { // redis 配置 type redis struct { + Network string Server string Password string DB string @@ -120,6 +125,7 @@ func Init(path string) { "Database": DatabaseConfig, "System": SystemConfig, "SSL": SSLConfig, + "Unix": UnixConfig, "Captcha": CaptchaConfig, "Redis": RedisConfig, "Thumbnail": ThumbConfig, diff --git a/pkg/conf/defaults.go b/pkg/conf/defaults.go index 406a203..3482cb8 100644 --- a/pkg/conf/defaults.go +++ b/pkg/conf/defaults.go @@ -4,6 +4,7 @@ import "github.com/mojocn/base64Captcha" // RedisConfig Redis服务器配置 var RedisConfig = &redis{ + Network: "tcp", Server: "", Password: "", DB: "0", @@ -65,3 +66,7 @@ var SSLConfig = &ssl{ CertPath: "", KeyPath: "", } + +var UnixConfig = &unix{ + Listen: "", +} From f478c3830779a1beba7d93015928355f089ebc42 Mon Sep 17 00:00:00 2001 From: mritd Date: Thu, 3 Sep 2020 12:05:00 +0800 Subject: [PATCH 02/34] chore(docker): add dockerfile (#549) * chore(docker): add dockerfile add dockerfile Signed-off-by: mritd * chore(docker): fix docker file fix docker file Signed-off-by: mritd * chore(docker): mv bin file to /cloudreve mv bin file to /cloudreve Signed-off-by: mritd * chore(docker): remove GOPROXY remove GOPROXY Signed-off-by: mritd --- Dockerfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ade3e2c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# build frontend +FROM node:lts-alpine3.12 AS fe-builder + +COPY ./assets /assets + +WORKDIR /assets + +RUN set -ex \ + && apk upgrade \ + && yarn install \ + && yarn run build + +# build backend +FROM golang:1.15.0-alpine3.12 AS be-builder + +ENV GO111MODULE on + +COPY . /go/src/github.com/HFO4/cloudreve +COPY --from=fe-builder /assets/build/ /go/src/github.com/HFO4/cloudreve/assets/build/ + +WORKDIR /go/src/github.com/HFO4/cloudreve + +RUN set -ex \ + && apk upgrade \ + && apk add gcc libc-dev git \ + && export COMMIT_SHA=$(git rev-parse --short HEAD) \ + && export VERSION=$(git describe --tags) \ + && (cd && go get github.com/rakyll/statik) \ + && statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f \ + && go install -ldflags "-X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=${VERSION}' \ + -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=${COMMIT_SHA}'\ + -w -s" + +# build final image +FROM alpine:3.12 AS dist + +LABEL maintainer="mritd " + +COPY --from=be-builder /go/bin/cloudreve /cloudreve/cloudreve + +RUN apk upgrade \ + && apk add bash tzdata \ + && ln -s /cloudreve/cloudreve /usr/bin/cloudreve \ + && rm -rf /var/cache/apk/* + +ENTRYPOINT ["cloudreve"] From 7df09537e02bfa7086e8d8bbe0b49f1cdbbe8e55 Mon Sep 17 00:00:00 2001 From: mritd Date: Thu, 3 Sep 2020 12:07:38 +0800 Subject: [PATCH 03/34] fix(db_driver): fix the panic when sqlite3 is used in the conf (#551) * fix(db_driver): fix the panic when sqlite3 is used in the conf fix the panic when sqlite3 is used in the conf ref cloudreve/Cloudreve#550 Signed-off-by: mritd * fix(nullpointer): fix possible null pointer error fix possible null pointer error Signed-off-by: mritd --- models/init.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/models/init.go b/models/init.go index 9153f01..80a6b3d 100644 --- a/models/init.go +++ b/models/init.go @@ -2,11 +2,12 @@ package model import ( "fmt" + "time" + "github.com/HFO4/cloudreve/pkg/conf" "github.com/HFO4/cloudreve/pkg/util" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" - "time" _ "github.com/jinzhu/gorm/dialects/mysql" _ "github.com/jinzhu/gorm/dialects/sqlite" @@ -28,19 +29,30 @@ func Init() { // 测试模式下,使用内存数据库 db, err = gorm.Open("sqlite3", ":memory:") } else { - if conf.DatabaseConfig.Type == "UNSET" { - // 未指定数据库时,使用SQLite + switch conf.DatabaseConfig.Type { + case "UNSET", "sqlite", "sqlite3": + // 未指定数据库或者明确指定为 sqlite 时,使用 SQLite3 数据库 db, err = gorm.Open("sqlite3", util.RelativePath(conf.DatabaseConfig.DBFile)) - } else { - db, err = gorm.Open(conf.DatabaseConfig.Type, fmt.Sprintf("%s:%s@(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", + case "mysql": + // 当前只支持 sqlite3 与 mysql 数据库 + // TODO: import 其他 gorm 支持的主流数据库?否则直接 Open 没有任何意义。 + // TODO: 数据库连接其他参数允许用户自定义?譬如编码更换为 utf8mb4 以支持表情。 + db, err = gorm.Open("mysql", fmt.Sprintf("%s:%s@(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", conf.DatabaseConfig.User, conf.DatabaseConfig.Password, conf.DatabaseConfig.Host, conf.DatabaseConfig.Port, conf.DatabaseConfig.Name)) + default: + util.Log().Panic("不支持数据库类型: %s", conf.DatabaseConfig.Type) } } + //db.SetLogger(util.Log()) + if err != nil { + util.Log().Panic("连接数据库不成功, %s", err) + } + // 处理表前缀 gorm.DefaultTableNameHandler = func(db *gorm.DB, defaultTableName string) string { return conf.DatabaseConfig.TablePrefix + defaultTableName @@ -53,11 +65,6 @@ func Init() { db.LogMode(false) } - //db.SetLogger(util.Log()) - if err != nil { - util.Log().Panic("连接数据库不成功, %s", err) - } - //设置连接池 //空闲 db.DB().SetMaxIdleConns(50) From 40414fe6ae9f629051ad4ffef1292fdf5997c6f9 Mon Sep 17 00:00:00 2001 From: mritd Date: Wed, 9 Sep 2020 14:56:14 +0800 Subject: [PATCH 04/34] chore(dockerfile): update node image to lts-buster (#557) * chore(dockerfile): update node image to lts-buster update node image to lts-buster, because the alpine image cannot be obtained on arm/arm64, it will support `docker buildx` build after the upgrade. Signed-off-by: mritd * chore(docker): update golang build image update golang build image Signed-off-by: mritd --- Dockerfile | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ade3e2c..6c8d015 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ # build frontend -FROM node:lts-alpine3.12 AS fe-builder +FROM node:lts-buster AS fe-builder COPY ./assets /assets WORKDIR /assets +# yarn repo connection is unstable, adjust the network timeout to 10 min. RUN set -ex \ - && apk upgrade \ - && yarn install \ + && yarn install --network-timeout 600000 \ && yarn run build # build backend -FROM golang:1.15.0-alpine3.12 AS be-builder +FROM golang:1.15.1-alpine3.12 AS be-builder ENV GO111MODULE on @@ -36,11 +36,30 @@ FROM alpine:3.12 AS dist LABEL maintainer="mritd " +# we use the Asia/Shanghai timezone by default, you can be modified +# by `docker build --build-arg=TZ=Other_Timezone ...` +ARG TZ="Asia/Shanghai" + +ENV TZ ${TZ} + COPY --from=be-builder /go/bin/cloudreve /cloudreve/cloudreve RUN apk upgrade \ && apk add bash tzdata \ && ln -s /cloudreve/cloudreve /usr/bin/cloudreve \ + && ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \ + && echo ${TZ} > /etc/timezone \ && rm -rf /var/cache/apk/* +# cloudreve use tcp 5212 port by default +EXPOSE 5212/tcp + +# cloudreve stores all files(including executable file) in the `/cloudreve` +# directory by default; users should mount the configfile to the `/etc/cloudreve` +# directory by themselves for persistence considerations, and the data storage +# directory recommends using `/data` directory. +VOLUME /etc/cloudreve + +VOLUME /data + ENTRYPOINT ["cloudreve"] From 41eb84a22156406d364f34ac4bcb6560aa7fb2f3 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sat, 10 Oct 2020 13:38:39 +0800 Subject: [PATCH 05/34] Update submodule version --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 1450cf1..8f2a9c3 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1450cf140b88e4c9a01197f5504cc3c95fecd748 +Subproject commit 8f2a9c3d8138e5726fa841d239ca3a2bd946dc1b From 77394313aa27c94cd47d4d95d79f4f5f686fda6c Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 11 Oct 2020 13:05:14 +0800 Subject: [PATCH 06/34] Fix: S3 adaption for minio --- assets | 2 +- models/policy.go | 15 ++++++++++++--- pkg/filesystem/driver/s3/handler.go | 1 + routers/controllers/callback.go | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/assets b/assets index 8f2a9c3..f342a2a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8f2a9c3d8138e5726fa841d239ca3a2bd946dc1b +Subproject commit f342a2a7774c5163f8d5a6760b556b69d6fe498f diff --git a/models/policy.go b/models/policy.go index e9aec07..f8255df 100644 --- a/models/policy.go +++ b/models/policy.go @@ -3,6 +3,7 @@ package model import ( "encoding/gob" "encoding/json" + "fmt" "net/url" "path" "path/filepath" @@ -239,7 +240,7 @@ func (policy *Policy) GetUploadURL() string { return policy.Server } - var controller *url.URL + controller, _ := url.Parse("") switch policy.Type { case "local", "onedrive": return "/api/v3/file/upload" @@ -251,9 +252,17 @@ func (policy *Policy) GetUploadURL() string { return policy.Server case "upyun": return "https://v0.api.upyun.com/" + policy.BucketName - default: - controller, _ = url.Parse("") + case "s3": + if policy.Server == "" { + return fmt.Sprintf("https://%s.s3.%s.amazonaws.com/", policy.BucketName, + policy.OptionsSerialized.Region) + } + + if !strings.Contains(policy.Server, policy.BucketName) { + controller, _ = url.Parse("/" + policy.BucketName) + } } + return server.ResolveReference(controller).String() } diff --git a/pkg/filesystem/driver/s3/handler.go b/pkg/filesystem/driver/s3/handler.go index 9283bac..9ebf951 100644 --- a/pkg/filesystem/driver/s3/handler.go +++ b/pkg/filesystem/driver/s3/handler.go @@ -62,6 +62,7 @@ func (handler *Driver) InitS3Client() error { Region: &handler.Policy.OptionsSerialized.Region, S3ForcePathStyle: aws.Bool(false), }) + if err != nil { return err } diff --git a/routers/controllers/callback.go b/routers/controllers/callback.go index 16d6e79..3d80d44 100644 --- a/routers/controllers/callback.go +++ b/routers/controllers/callback.go @@ -110,6 +110,7 @@ func COSCallback(c *gin.Context) { // S3Callback S3上传完成客户端回调 func S3Callback(c *gin.Context) { + c.Header("Access-Control-Allow-Origin", "*") var callbackBody callback.S3Callback if err := c.ShouldBindQuery(&callbackBody); err == nil { res := callbackBody.PreProcess(c) From 95f318e069a0642f8eaa642b2b71e3b235b07724 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 26 Oct 2020 15:06:02 +0800 Subject: [PATCH 07/34] Feat: adapt minio for S3 policy and fix listing files --- assets | 2 +- models/policy.go | 2 +- pkg/filesystem/driver/s3/handler.go | 7 +++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/assets b/assets index f342a2a..8ec4514 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit f342a2a7774c5163f8d5a6760b556b69d6fe498f +Subproject commit 8ec4514b7690eef20b283c1f00ee2d921f19ae7d diff --git a/models/policy.go b/models/policy.go index f8255df..61fd171 100644 --- a/models/policy.go +++ b/models/policy.go @@ -52,7 +52,7 @@ type PolicyOption struct { OdRedirect string `json:"od_redirect,omitempty"` // Region 区域代码 - Region string `json:"region"` + Region string `json:"region,omitempty"` } var thumbSuffix = map[string][]string{ diff --git a/pkg/filesystem/driver/s3/handler.go b/pkg/filesystem/driver/s3/handler.go index 9ebf951..4cf44e2 100644 --- a/pkg/filesystem/driver/s3/handler.go +++ b/pkg/filesystem/driver/s3/handler.go @@ -87,10 +87,9 @@ func (handler Driver) List(ctx context.Context, base string, recursive bool) ([] } opt := &s3.ListObjectsInput{ - Bucket: &handler.Policy.BucketName, - Prefix: &base, - EncodingType: aws.String(""), - MaxKeys: aws.Int64(1000), + Bucket: &handler.Policy.BucketName, + Prefix: &base, + MaxKeys: aws.Int64(1000), } // 是否为递归列出 From 746aa3e8ef26fb0669fca11a1edcd560d8818b72 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 26 Oct 2020 15:33:28 +0800 Subject: [PATCH 08/34] Test: s3 policy --- go.sum | 1 + middleware/auth.go | 24 ++++++++--------- middleware/auth_test.go | 44 +++++++++++++++++++++++++++++++ models/policy_test.go | 22 ++++++++++++++++ pkg/filesystem/filesystem_test.go | 4 +++ pkg/serializer/upload.go | 4 +-- routers/controllers/callback.go | 2 +- 7 files changed, 86 insertions(+), 15 deletions(-) diff --git a/go.sum b/go.sum index 00f2c4d..bb6ef14 100644 --- a/go.sum +++ b/go.sum @@ -239,6 +239,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/tencentcloud/tencentcloud-sdk-go v3.0.125+incompatible h1:dqpmYaez7VBT7PCRBcBxkzlDOiTk7Td8ATiia1b1GuE= github.com/tencentcloud/tencentcloud-sdk-go v3.0.125+incompatible/go.mod h1:0PfYow01SHPMhKY31xa+EFz2RStxIqj6JFAJS+IkCi4= diff --git a/middleware/auth.go b/middleware/auth.go index 33924f1..cd2fe43 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -175,7 +175,7 @@ func QiniuCallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, user := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } @@ -185,12 +185,12 @@ func QiniuCallbackAuth() gin.HandlerFunc { ok, err := mac.VerifyCallback(c.Request) if err != nil { util.Log().Debug("无法验证回调请求,%s", err) - c.JSON(401, serializer.QiniuCallbackFailed{Error: "无法验证回调请求"}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: "无法验证回调请求"}) c.Abort() return } if !ok { - c.JSON(401, serializer.QiniuCallbackFailed{Error: "回调签名无效"}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: "回调签名无效"}) c.Abort() return } @@ -205,7 +205,7 @@ func OSSCallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, _ := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } @@ -213,7 +213,7 @@ func OSSCallbackAuth() gin.HandlerFunc { err := oss.VerifyCallbackSignature(c.Request) if err != nil { util.Log().Debug("回调签名验证失败,%s", err) - c.JSON(401, serializer.QiniuCallbackFailed{Error: "回调签名验证失败"}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: "回调签名验证失败"}) c.Abort() return } @@ -228,7 +228,7 @@ func UpyunCallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, user := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } @@ -237,7 +237,7 @@ func UpyunCallbackAuth() gin.HandlerFunc { body, err := ioutil.ReadAll(c.Request.Body) c.Request.Body.Close() if err != nil { - c.JSON(401, serializer.QiniuCallbackFailed{Error: err.Error()}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: err.Error()}) c.Abort() return } @@ -253,7 +253,7 @@ func UpyunCallbackAuth() gin.HandlerFunc { // 计算正文MD5 actualContentMD5 := fmt.Sprintf("%x", md5.Sum(body)) if actualContentMD5 != contentMD5 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: "MD5不一致"}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: "MD5不一致"}) c.Abort() return } @@ -268,7 +268,7 @@ func UpyunCallbackAuth() gin.HandlerFunc { // 对比签名 if signature != actualSignature { - c.JSON(401, serializer.QiniuCallbackFailed{Error: "鉴权失败"}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: "鉴权失败"}) c.Abort() return } @@ -284,7 +284,7 @@ func OneDriveCallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, _ := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } @@ -303,7 +303,7 @@ func COSCallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, _ := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } @@ -318,7 +318,7 @@ func S3CallbackAuth() gin.HandlerFunc { // 验证key并查找用户 resp, _ := uploadCallbackCheck(c) if resp.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: resp.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: resp.Msg}) c.Abort() return } diff --git a/middleware/auth_test.go b/middleware/auth_test.go index 2f60f6c..e2531e3 100644 --- a/middleware/auth_test.go +++ b/middleware/auth_test.go @@ -747,3 +747,47 @@ func TestIsAdmin(t *testing.T) { asserts.False(c.IsAborted()) } } + +func TestS3CallbackAuth(t *testing.T) { + asserts := assert.New(t) + rec := httptest.NewRecorder() + AuthFunc := S3CallbackAuth() + + // Callback Key 相关验证失败 + { + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{ + {"key", "testUpyunBackRemote"}, + } + c.Request, _ = http.NewRequest("POST", "/api/v3/callback/upyun/testUpyunBackRemote", nil) + AuthFunc(c) + asserts.True(c.IsAborted()) + } + + // 成功 + { + cache.Set( + "callback_testCallBackUpyun", + serializer.UploadSession{ + UID: 1, + PolicyID: 512, + VirtualPath: "/", + }, + 0, + ) + cache.Deletes([]string{"1"}, "policy_") + mock.ExpectQuery("SELECT(.+)users(.+)"). + WillReturnRows(sqlmock.NewRows([]string{"id", "group_id"}).AddRow(1, 1)) + mock.ExpectQuery("SELECT(.+)groups(.+)"). + WillReturnRows(sqlmock.NewRows([]string{"id", "policies"}).AddRow(1, "[702]")) + mock.ExpectQuery("SELECT(.+)policies(.+)"). + WillReturnRows(sqlmock.NewRows([]string{"id", "access_key", "secret_key"}).AddRow(2, "123", "123")) + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{ + {"key", "testCallBackUpyun"}, + } + c.Request, _ = http.NewRequest("POST", "/api/v3/callback/upyun/testCallBackUpyun", ioutil.NopCloser(strings.NewReader("1"))) + AuthFunc(c) + asserts.False(c.IsAborted()) + } +} diff --git a/models/policy_test.go b/models/policy_test.go index a079d8e..5519ff6 100644 --- a/models/policy_test.go +++ b/models/policy_test.go @@ -209,6 +209,28 @@ func TestPolicy_GetUploadURL(t *testing.T) { asserts.Equal("http://127.0.0.1", policy.GetUploadURL()) } + // S3 未填写自动生成 + { + policy := Policy{ + Type: "s3", + Server: "", + BucketName: "bucket", + OptionsSerialized: PolicyOption{Region: "us-east"}, + } + asserts.Equal("https://bucket.s3.us-east.amazonaws.com/", policy.GetUploadURL()) + } + + // s3 自己指定 + { + policy := Policy{ + Type: "s3", + Server: "https://s3.us-east.amazonaws.com/", + BucketName: "bucket", + OptionsSerialized: PolicyOption{Region: "us-east"}, + } + asserts.Equal("https://s3.us-east.amazonaws.com/bucket", policy.GetUploadURL()) + } + } func TestPolicy_IsPathGenerateNeeded(t *testing.T) { diff --git a/pkg/filesystem/filesystem_test.go b/pkg/filesystem/filesystem_test.go index f699b6d..140024f 100644 --- a/pkg/filesystem/filesystem_test.go +++ b/pkg/filesystem/filesystem_test.go @@ -102,6 +102,10 @@ func TestDispatchHandler(t *testing.T) { fs.Policy = &model.Policy{Type: "onedrive"} err = fs.DispatchHandler() asserts.NoError(err) + + fs.Policy = &model.Policy{Type: "s3"} + err = fs.DispatchHandler() + asserts.NoError(err) } func TestNewFileSystemFromCallback(t *testing.T) { diff --git a/pkg/serializer/upload.go b/pkg/serializer/upload.go index c473483..426ad40 100644 --- a/pkg/serializer/upload.go +++ b/pkg/serializer/upload.go @@ -46,8 +46,8 @@ type UploadCallback struct { Size uint64 `json:"size"` } -// QiniuCallbackFailed 七牛存储策略上传回调失败响应 -type QiniuCallbackFailed struct { +// GeneralUploadCallbackFailed 存储策略上传回调失败响应 +type GeneralUploadCallbackFailed struct { Error string `json:"error"` } diff --git a/routers/controllers/callback.go b/routers/controllers/callback.go index 3d80d44..69f93bb 100644 --- a/routers/controllers/callback.go +++ b/routers/controllers/callback.go @@ -27,7 +27,7 @@ func QiniuCallback(c *gin.Context) { if err := c.ShouldBindJSON(&callbackBody); err == nil { res := callback.ProcessCallback(callbackBody, c) if res.Code != 0 { - c.JSON(401, serializer.QiniuCallbackFailed{Error: res.Msg}) + c.JSON(401, serializer.GeneralUploadCallbackFailed{Error: res.Msg}) } else { c.JSON(200, res) } From 59d50b1b98c7d0370a3cb44ec950bd946945491d Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 26 Oct 2020 15:42:18 +0800 Subject: [PATCH 09/34] Modify: change `Unix` to `UnixSocket` in config section --- pkg/conf/conf.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 43f2481..dbec5df 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -34,7 +34,7 @@ type ssl struct { } type unix struct { - Listen string + Listen string } // slave 作为slave存储端配置 @@ -122,15 +122,15 @@ func Init(path string) { } sections := map[string]interface{}{ - "Database": DatabaseConfig, - "System": SystemConfig, - "SSL": SSLConfig, - "Unix": UnixConfig, - "Captcha": CaptchaConfig, - "Redis": RedisConfig, - "Thumbnail": ThumbConfig, - "CORS": CORSConfig, - "Slave": SlaveConfig, + "Database": DatabaseConfig, + "System": SystemConfig, + "SSL": SSLConfig, + "UnixSocket": UnixConfig, + "Captcha": CaptchaConfig, + "Redis": RedisConfig, + "Thumbnail": ThumbConfig, + "CORS": CORSConfig, + "Slave": SlaveConfig, } for sectionName, sectionStruct := range sections { err = mapSection(sectionName, sectionStruct) From 79b8784934a6153de1cac9b309105bd1d489fb5a Mon Sep 17 00:00:00 2001 From: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Sat, 21 Nov 2020 17:34:55 +0800 Subject: [PATCH 10/34] Comply with Golang semantic import versioning (#630) * Code: compatible with semantic import versioning * Tools & Docs: compatible with semantic import versioning * Clean go.mod & go.sum --- Dockerfile | 10 +++---- README.md | 2 +- bootstrap/app.go | 7 +++-- bootstrap/init.go | 16 +++++------ bootstrap/static.go | 10 +++---- build.sh | 6 ++-- go.mod | 5 +--- go.sum | 21 +------------- main.go | 9 +++--- middleware/auth.go | 16 +++++------ middleware/auth_test.go | 21 +++++++------- middleware/mock.go | 2 +- middleware/mock_test.go | 7 +++-- middleware/option.go | 13 +++++---- middleware/option_test.go | 15 +++++----- middleware/session.go | 6 ++-- middleware/session_test.go | 9 +++--- middleware/share.go | 7 +++-- middleware/share_test.go | 9 +++--- models/download.go | 5 ++-- models/file.go | 5 ++-- models/folder.go | 5 ++-- models/folder_test.go | 9 +++--- models/init.go | 4 +-- models/migration.go | 6 ++-- models/migration_test.go | 5 ++-- models/policy.go | 4 +-- models/policy_test.go | 9 +++--- models/setting.go | 5 ++-- models/setting_test.go | 5 ++-- models/share.go | 11 ++++---- models/share_test.go | 13 +++++---- models/tag.go | 2 +- models/task.go | 2 +- models/user.go | 5 ++-- models/user_authn.go | 5 ++-- models/user_test.go | 5 ++-- pkg/aria2/aria2.go | 9 +++--- pkg/aria2/aria2_test.go | 7 +++-- pkg/aria2/caller.go | 7 +++-- pkg/aria2/caller_test.go | 7 +++-- pkg/aria2/monitor.go | 15 +++++----- pkg/aria2/monitor_test.go | 17 +++++------ pkg/aria2/notification.go | 3 +- pkg/aria2/notification_test.go | 5 ++-- pkg/auth/auth.go | 9 +++--- pkg/auth/auth_test.go | 5 ++-- pkg/auth/hmac_test.go | 11 ++++---- pkg/authn/auth.go | 2 +- pkg/authn/auth_test.go | 5 ++-- pkg/cache/driver.go | 2 +- pkg/cache/memo.go | 3 +- pkg/cache/redis.go | 5 ++-- pkg/conf/conf.go | 4 +-- pkg/conf/conf_test.go | 5 ++-- pkg/crontab/collect.go | 7 +++-- pkg/crontab/init.go | 4 +-- pkg/email/init.go | 5 ++-- pkg/email/smtp.go | 5 ++-- pkg/email/template.go | 5 ++-- pkg/filesystem/archive.go | 13 +++++---- pkg/filesystem/archive_test.go | 19 +++++++------ pkg/filesystem/driver/cos/handler.go | 15 +++++----- pkg/filesystem/driver/cos/scf.go | 11 ++++---- pkg/filesystem/driver/local/handler.go | 17 +++++------ pkg/filesystem/driver/local/handler_test.go | 15 +++++----- pkg/filesystem/driver/onedrive/api.go | 11 ++++---- pkg/filesystem/driver/onedrive/api_test.go | 11 ++++---- pkg/filesystem/driver/onedrive/client.go | 5 ++-- pkg/filesystem/driver/onedrive/client_test.go | 5 ++-- pkg/filesystem/driver/onedrive/handler.go | 13 +++++---- .../driver/onedrive/handler_test.go | 17 +++++------ pkg/filesystem/driver/onedrive/oauth.go | 7 +++-- pkg/filesystem/driver/onedrive/oauth_test.go | 15 +++++----- pkg/filesystem/driver/oss/callback.go | 5 ++-- pkg/filesystem/driver/oss/callback_test.go | 5 ++-- pkg/filesystem/driver/oss/handler.go | 15 +++++----- pkg/filesystem/driver/oss/handler_test.go | 13 +++++---- pkg/filesystem/driver/qiniu/handler.go | 15 +++++----- pkg/filesystem/driver/remote/handler.go | 13 +++++---- pkg/filesystem/driver/remote/handler_test.go | 17 +++++------ pkg/filesystem/driver/s3/handler.go | 10 +++---- pkg/filesystem/driver/template/handler.go | 7 +++-- pkg/filesystem/driver/upyun/handler.go | 13 +++++---- pkg/filesystem/errors.go | 3 +- pkg/filesystem/file.go | 15 +++++----- pkg/filesystem/file_test.go | 21 +++++++------- pkg/filesystem/filesystem.go | 28 +++++++++---------- pkg/filesystem/filesystem_test.go | 13 +++++---- pkg/filesystem/hooks.go | 13 +++++---- pkg/filesystem/hooks_test.go | 23 +++++++-------- pkg/filesystem/image.go | 13 +++++---- pkg/filesystem/image_test.go | 9 +++--- pkg/filesystem/manage.go | 11 ++++---- pkg/filesystem/manage_test.go | 19 +++++++------ pkg/filesystem/path.go | 5 ++-- pkg/filesystem/path_test.go | 5 ++-- pkg/filesystem/upload.go | 17 +++++------ pkg/filesystem/upload_test.go | 21 +++++++------- pkg/filesystem/validator.go | 3 +- pkg/filesystem/validator_test.go | 7 +++-- pkg/hashid/hash.go | 5 ++-- pkg/request/request.go | 9 +++--- pkg/request/request_test.go | 7 +++-- pkg/request/slave.go | 7 +++-- pkg/request/slave_test.go | 7 +++-- pkg/serializer/aria2.go | 5 ++-- pkg/serializer/aria2_test.go | 9 +++--- pkg/serializer/setting.go | 2 +- pkg/serializer/setting_test.go | 5 ++-- pkg/serializer/share.go | 5 ++-- pkg/serializer/share_test.go | 7 +++-- pkg/serializer/user.go | 5 ++-- pkg/serializer/user_test.go | 7 +++-- pkg/task/compress.go | 7 +++-- pkg/task/compress_test.go | 9 +++--- pkg/task/decompress.go | 5 ++-- pkg/task/decompress_test.go | 5 ++-- pkg/task/import.go | 11 ++++---- pkg/task/import_test.go | 9 +++--- pkg/task/job.go | 4 +-- pkg/task/job_test.go | 7 +++-- pkg/task/pool.go | 4 +-- pkg/task/pool_test.go | 7 +++-- pkg/task/tranfer.go | 7 +++-- pkg/task/transfer_test.go | 5 ++-- pkg/task/worker.go | 2 +- pkg/task/worker_test.go | 5 ++-- pkg/thumb/image.go | 5 ++-- pkg/thumb/image_test.go | 7 +++-- pkg/webdav/file.go | 5 ++-- pkg/webdav/prop.go | 3 +- pkg/webdav/webdav.go | 11 ++++---- pkg/webdav/xml.go | 2 +- routers/controllers/admin.go | 13 +++++---- routers/controllers/aria2.go | 7 +++-- routers/controllers/callback.go | 6 ++-- routers/controllers/directory.go | 2 +- routers/controllers/file.go | 17 +++++------ routers/controllers/main.go | 5 ++-- routers/controllers/objects.go | 3 +- routers/controllers/share.go | 11 ++++---- routers/controllers/site.go | 8 +++--- routers/controllers/slave.go | 15 +++++----- routers/controllers/tag.go | 2 +- routers/controllers/user.go | 15 +++++----- routers/controllers/webdav.go | 10 +++---- routers/file_router_test.go | 11 ++++---- routers/main_test.go | 5 ++-- routers/router.go | 12 ++++---- routers/router_test.go | 7 +++-- service/admin/aria2.go | 5 ++-- service/admin/file.go | 13 +++++---- service/admin/group.go | 5 ++-- service/admin/list.go | 4 +-- service/admin/policy.go | 22 +++++++-------- service/admin/share.go | 9 +++--- service/admin/site.go | 11 ++++---- service/admin/task.go | 9 +++--- service/admin/user.go | 7 +++-- service/aria2/add.go | 8 +++--- service/aria2/manage.go | 6 ++-- service/callback/oauth.go | 11 ++++---- service/callback/upload.go | 16 +++++------ service/explorer/directory.go | 7 +++-- service/explorer/file.go | 17 +++++------ service/explorer/objects.go | 21 +++++++------- service/explorer/search.go | 11 ++++---- service/explorer/tag.go | 9 +++--- service/explorer/upload.go | 7 +++-- service/setting/webdav.go | 6 ++-- service/share/manage.go | 9 +++--- service/share/visit.go | 17 +++++------ service/user/login.go | 21 +++++++------- service/user/register.go | 19 +++++++------ service/user/setting.go | 11 ++++---- 176 files changed, 851 insertions(+), 735 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6c8d015..b9aa08b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,10 +15,10 @@ FROM golang:1.15.1-alpine3.12 AS be-builder ENV GO111MODULE on -COPY . /go/src/github.com/HFO4/cloudreve -COPY --from=fe-builder /assets/build/ /go/src/github.com/HFO4/cloudreve/assets/build/ +COPY . /go/src/github.com/cloudreve/Cloudreve/v3 +COPY --from=fe-builder /assets/build/ /go/src/github.com/cloudreve/Cloudreve/v3/assets/build/ -WORKDIR /go/src/github.com/HFO4/cloudreve +WORKDIR /go/src/github.com/cloudreve/Cloudreve/v3 RUN set -ex \ && apk upgrade \ @@ -27,8 +27,8 @@ RUN set -ex \ && export VERSION=$(git describe --tags) \ && (cd && go get github.com/rakyll/statik) \ && statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f \ - && go install -ldflags "-X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=${VERSION}' \ - -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=${COMMIT_SHA}'\ + && go install -ldflags "-X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=${VERSION}' \ + -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=${COMMIT_SHA}'\ -w -s" # build final image diff --git a/README.md b/README.md index e897210..4420f66 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ export COMMIT_SHA=$(git rev-parse --short HEAD) export VERSION=$(git describe --tags) # 开始编译 -go build -a -o cloudreve -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" +go build -a -o cloudreve -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'" ``` 你也可以使用项目根目录下的`build.sh`快速开始构建: diff --git a/bootstrap/app.go b/bootstrap/app.go index ccb4fdc..093e3f4 100644 --- a/bootstrap/app.go +++ b/bootstrap/app.go @@ -3,9 +3,10 @@ package bootstrap import ( "encoding/json" "fmt" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/util" + + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/hashicorp/go-version" ) diff --git a/bootstrap/init.go b/bootstrap/init.go index 91309a8..98f2c8d 100644 --- a/bootstrap/init.go +++ b/bootstrap/init.go @@ -1,14 +1,14 @@ package bootstrap import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/crontab" - "github.com/HFO4/cloudreve/pkg/email" - "github.com/HFO4/cloudreve/pkg/task" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/crontab" + "github.com/cloudreve/Cloudreve/v3/pkg/email" + "github.com/cloudreve/Cloudreve/v3/pkg/task" "github.com/gin-gonic/gin" ) diff --git a/bootstrap/static.go b/bootstrap/static.go index d3f8967..7b8a987 100644 --- a/bootstrap/static.go +++ b/bootstrap/static.go @@ -2,15 +2,15 @@ package bootstrap import ( "encoding/json" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" - _ "github.com/HFO4/cloudreve/statik" - "github.com/gin-contrib/static" - "github.com/rakyll/statik/fs" "io" "io/ioutil" "net/http" "path" + + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-contrib/static" + "github.com/rakyll/statik/fs" ) const StaticFolder = "statics" diff --git a/build.sh b/build.sh index ea7e101..dd18f3a 100755 --- a/build.sh +++ b/build.sh @@ -39,7 +39,7 @@ buildAssets () { buildBinary () { cd $REPO - go build -a -o cloudreve -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" + go build -a -o cloudreve -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'" } _build() { @@ -61,7 +61,7 @@ _build() { out="release/cloudreve_${COMMIT_SHA}_${os}_${arch}" fi - go build -a -o "${out}" -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$VERSION' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'" + go build -a -o "${out}" -ldflags " -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.BackendVersion=$VERSION' -X 'github.com/cloudreve/Cloudreve/v3/pkg/conf.LastCommit=$COMMIT_SHA'" if [ "$os" = "windows" ]; then mv $out release/cloudreve.exe @@ -130,4 +130,4 @@ fi if [ "$RELEASE" = "true" ]; then release -fi \ No newline at end of file +fi diff --git a/go.mod b/go.mod index 2b38ee4..e7233f5 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/HFO4/cloudreve +module github.com/cloudreve/Cloudreve/v3 go 1.13 @@ -16,7 +16,6 @@ require ( github.com/gin-gonic/gin v1.5.0 github.com/go-ini/ini v1.50.0 github.com/go-mail/mail v2.3.1+incompatible - github.com/gofrs/uuid v3.2.0+incompatible github.com/gomodule/redigo v2.0.0+incompatible github.com/google/go-querystring v1.0.0 github.com/gorilla/websocket v1.4.1 @@ -28,12 +27,10 @@ require ( github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/pkg/errors v0.9.1 github.com/pquerna/otp v1.2.0 - github.com/qingwg/payjs v0.0.0-20190928033402-c53dbe16b371 github.com/qiniu/api.v7/v7 v7.4.0 github.com/rafaeljusto/redigomock v0.0.0-20191117212112-00b2509252a1 github.com/rakyll/statik v0.1.7 github.com/robfig/cron/v3 v3.0.1 - github.com/smartwalle/alipay/v3 v3.0.13 github.com/smartystreets/goconvey v1.6.4 // indirect github.com/speps/go-hashids v2.0.0+incompatible github.com/stretchr/testify v1.5.1 diff --git a/go.sum b/go.sum index bb6ef14..280b0f8 100644 --- a/go.sum +++ b/go.sum @@ -54,13 +54,11 @@ github.com/gin-contrib/gzip v0.0.2-0.20200226035851-25bef2ef21e8 h1:/DnKeA2+K83h github.com/gin-contrib/gzip v0.0.2-0.20200226035851-25bef2ef21e8/go.mod h1:M+xPw/lXk+uAU4iYVnwPZs0iIpR/KwSQSXcJabN+gPs= github.com/gin-contrib/sessions v0.0.1 h1:xr9V/u3ERQnkugKSY/u36cNnC4US4bHJpdxcB6eIZLk= github.com/gin-contrib/sessions v0.0.1/go.mod h1:iziXm/6pvTtf7og1uxT499sel4h3S9DfwsrhNZ+REXM= -github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3 h1:t8FVkw33L+wilf2QiWkw0UV77qRpcH/JHPKGpKa2E8g= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2 h1:xLG16iua01X7Gzms9045s2Y2niNpvSY/Zb1oBwgNYZY= github.com/gin-contrib/static v0.0.0-20191128031702-f81c604d8ac2/go.mod h1:VhW/Ch/3FhimwZb8Oj+qJmdMmoB8r7lmJ5auRjm50oQ= -github.com/gin-gonic/gin v1.4.0 h1:3tMoCCfM7ppqsR0ptz/wi1impNpT7/9wQtMZ8lr1mCQ= github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM= github.com/gin-gonic/gin v1.5.0 h1:fi+bqFAx/oLK54somfCtEZs9HeH1LHVoEPUgARpTqyc= github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= @@ -75,13 +73,10 @@ github.com/go-playground/locales v0.12.1 h1:2FITxuFt/xuCNP1Acdhv62OzaCiviiE4kotf github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rmGrCjJ8eAeUP/K/EKx4DM= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= -github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= -github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= @@ -90,7 +85,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -162,7 +156,6 @@ github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= @@ -190,7 +183,6 @@ github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= -github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -205,8 +197,6 @@ github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1: github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/qingwg/payjs v0.0.0-20190928033402-c53dbe16b371 h1:8VWtyY2IwjEQZSNT4Kyyct9zv9hoegD5GQhFr+TMdCI= -github.com/qingwg/payjs v0.0.0-20190928033402-c53dbe16b371/go.mod h1:9UFrQveqNm3ELF6HSvMtDR3KYpJ7Ib9s0WVmYhaUBlU= github.com/qiniu/api.v7/v7 v7.4.0 h1:9dZMVQifh31QGFLVaHls6akCaS2rlj3du8MnEFd7XjQ= github.com/qiniu/api.v7/v7 v7.4.0/go.mod h1:VE5oC5rkE1xul0u1S2N0b2Uxq9/6hZzhyqjgK25XDcM= github.com/quasoft/memstore v0.0.0-20180925164028-84a050167438 h1:jnz/4VenymvySjE+Ez511s0pqVzkUOmr1fwCVytNNWk= @@ -221,10 +211,6 @@ github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzG github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/smartwalle/alipay/v3 v3.0.13 h1:f1Cdnxh6TfbaziLw0i/4h+f8tw9RJwG8y4xye7vTTgY= -github.com/smartwalle/alipay/v3 v3.0.13/go.mod h1:cZUMCCnsux9YAxA0/f3PWUR+7wckWtE1BqxbVRtGij0= -github.com/smartwalle/crypto4go v1.0.2 h1:9DUEOOsPhmp00438L4oBdcL8EZG1zumecft5bWj5phI= -github.com/smartwalle/crypto4go v1.0.2/go.mod h1:LQ7vCZIb7BE5+MuMtJBuO8ORkkQ01m4DXDBWPzLbkMY= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= @@ -237,7 +223,6 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -256,7 +241,6 @@ go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190506204251-e1dfcc566284/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -276,8 +260,8 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80 h1:Ao/3l156eZf2AW5wK8a7/smtodRU+gha3+BeqJ69lRk= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -295,7 +279,6 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -314,7 +297,6 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -330,7 +312,6 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= -gopkg.in/go-playground/validator.v8 v8.18.2 h1:lFB4DoMU6B626w8ny76MV7VX6W2VHct2GVOI3xgiMrQ= gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y= gopkg.in/go-playground/validator.v9 v9.29.1 h1:SvGtYmN60a5CVKTOzMSyfzWDeZRxRuGvRQyEAKbw1xc= gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= diff --git a/main.go b/main.go index 558a66a..d1b4e53 100644 --- a/main.go +++ b/main.go @@ -2,10 +2,11 @@ package main import ( "flag" - "github.com/HFO4/cloudreve/bootstrap" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/routers" + + "github.com/cloudreve/Cloudreve/v3/bootstrap" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/routers" ) var ( diff --git a/middleware/auth.go b/middleware/auth.go index cd2fe43..ca68f0e 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -8,14 +8,14 @@ import ( "io/ioutil" "net/http" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/onedrive" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/oss" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/upyun" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/oss" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/upyun" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" "github.com/qiniu/api.v7/v7/auth/qbox" diff --git a/middleware/auth_test.go b/middleware/auth_test.go index e2531e3..95ab75c 100644 --- a/middleware/auth_test.go +++ b/middleware/auth_test.go @@ -3,21 +3,22 @@ package middleware import ( "database/sql" "errors" - "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/jinzhu/gorm" - "github.com/qiniu/api.v7/v7/auth/qbox" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" + "github.com/qiniu/api.v7/v7/auth/qbox" + "github.com/stretchr/testify/assert" ) var mock sqlmock.Sqlmock diff --git a/middleware/mock.go b/middleware/mock.go index 482b080..d026e77 100644 --- a/middleware/mock.go +++ b/middleware/mock.go @@ -1,7 +1,7 @@ package middleware import ( - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) diff --git a/middleware/mock_test.go b/middleware/mock_test.go index cc715b1..1ebee20 100644 --- a/middleware/mock_test.go +++ b/middleware/mock_test.go @@ -1,12 +1,13 @@ package middleware import ( - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" ) func TestMockHelper(t *testing.T) { diff --git a/middleware/option.go b/middleware/option.go index 3aaf619..6704bcf 100644 --- a/middleware/option.go +++ b/middleware/option.go @@ -1,13 +1,14 @@ package middleware import ( - "github.com/HFO4/cloudreve/bootstrap" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" "io/ioutil" + + "github.com/cloudreve/Cloudreve/v3/bootstrap" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" ) // HashID 将给定对象的HashID转换为真实ID diff --git a/middleware/option_test.go b/middleware/option_test.go index 1a75f61..512c2e8 100644 --- a/middleware/option_test.go +++ b/middleware/option_test.go @@ -2,17 +2,18 @@ package middleware import ( "errors" - "github.com/HFO4/cloudreve/bootstrap" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "net/http" "net/http/httptest" "os" "testing" + + "github.com/cloudreve/Cloudreve/v3/bootstrap" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestHashID(t *testing.T) { diff --git a/middleware/session.go b/middleware/session.go index f89609d..9c3b679 100644 --- a/middleware/session.go +++ b/middleware/session.go @@ -1,9 +1,9 @@ package middleware import ( - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-contrib/sessions" "github.com/gin-contrib/sessions/memstore" "github.com/gin-contrib/sessions/redis" diff --git a/middleware/session_test.go b/middleware/session_test.go index 674f4bd..ac9403c 100644 --- a/middleware/session_test.go +++ b/middleware/session_test.go @@ -1,13 +1,14 @@ package middleware import ( - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" ) func TestSession(t *testing.T) { diff --git a/middleware/share.go b/middleware/share.go index a67a67b..99e5647 100644 --- a/middleware/share.go +++ b/middleware/share.go @@ -2,9 +2,10 @@ package middleware import ( "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) diff --git a/middleware/share_test.go b/middleware/share_test.go index 6b75c30..129076b 100644 --- a/middleware/share_test.go +++ b/middleware/share_test.go @@ -1,14 +1,15 @@ package middleware import ( + "net/http/httptest" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "net/http/httptest" - "testing" ) func TestShareAvailable(t *testing.T) { diff --git a/models/download.go b/models/download.go index da47b95..e73ae5f 100644 --- a/models/download.go +++ b/models/download.go @@ -2,8 +2,9 @@ package model import ( "encoding/json" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/util" + + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" ) diff --git a/models/file.go b/models/file.go index 54de0f5..bc2f011 100644 --- a/models/file.go +++ b/models/file.go @@ -2,10 +2,11 @@ package model import ( "encoding/gob" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/jinzhu/gorm" "path" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/jinzhu/gorm" ) // File 文件 diff --git a/models/folder.go b/models/folder.go index 1366f71..70c5509 100644 --- a/models/folder.go +++ b/models/folder.go @@ -2,10 +2,11 @@ package model import ( "errors" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/jinzhu/gorm" "path" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/jinzhu/gorm" ) // Folder 目录 diff --git a/models/folder_test.go b/models/folder_test.go index 1996c6d..0ccd821 100644 --- a/models/folder_test.go +++ b/models/folder_test.go @@ -2,12 +2,13 @@ package model import ( "errors" - "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "testing" "time" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestFolder_Create(t *testing.T) { diff --git a/models/init.go b/models/init.go index 80a6b3d..02af046 100644 --- a/models/init.go +++ b/models/init.go @@ -4,8 +4,8 @@ import ( "fmt" "time" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" diff --git a/models/migration.go b/models/migration.go index 85969e4..4683d81 100644 --- a/models/migration.go +++ b/models/migration.go @@ -1,9 +1,9 @@ package model import ( - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/fatih/color" "github.com/jinzhu/gorm" ) diff --git a/models/migration_test.go b/models/migration_test.go index 5c1cf8c..55faefe 100644 --- a/models/migration_test.go +++ b/models/migration_test.go @@ -1,10 +1,11 @@ package model import ( - "github.com/HFO4/cloudreve/pkg/conf" + "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestMigration(t *testing.T) { diff --git a/models/policy.go b/models/policy.go index 61fd171..7c0dee4 100644 --- a/models/policy.go +++ b/models/policy.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" ) diff --git a/models/policy_test.go b/models/policy_test.go index 5519ff6..6168148 100644 --- a/models/policy_test.go +++ b/models/policy_test.go @@ -2,13 +2,14 @@ package model import ( "encoding/json" - "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "strconv" "testing" "time" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestGetPolicyByID(t *testing.T) { diff --git a/models/setting.go b/models/setting.go index d14cf72..f8157cf 100644 --- a/models/setting.go +++ b/models/setting.go @@ -1,10 +1,11 @@ package model import ( - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/jinzhu/gorm" "net/url" "strconv" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/jinzhu/gorm" ) // Setting 系统设置模型 diff --git a/models/setting_test.go b/models/setting_test.go index e6c716c..d9bf962 100644 --- a/models/setting_test.go +++ b/models/setting_test.go @@ -2,11 +2,12 @@ package model import ( "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) var mock sqlmock.Sqlmock diff --git a/models/share.go b/models/share.go index 535a04a..137e745 100644 --- a/models/share.go +++ b/models/share.go @@ -3,13 +3,14 @@ package model import ( "errors" "fmt" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/jinzhu/gorm" "strings" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" ) // Share 分享模型 diff --git a/models/share_test.go b/models/share_test.go index 0f0c185..52e2ee6 100644 --- a/models/share_test.go +++ b/models/share_test.go @@ -2,15 +2,16 @@ package model import ( "errors" - "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/gin-gonic/gin" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "net/http/httptest" "testing" "time" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestShare_Create(t *testing.T) { diff --git a/models/tag.go b/models/tag.go index 92c9a9e..5c5250f 100644 --- a/models/tag.go +++ b/models/tag.go @@ -1,7 +1,7 @@ package model import ( - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" ) diff --git a/models/task.go b/models/task.go index 01ec5e5..e880f85 100644 --- a/models/task.go +++ b/models/task.go @@ -1,7 +1,7 @@ package model import ( - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" ) diff --git a/models/user.go b/models/user.go index b6ae0fb..c4226f0 100644 --- a/models/user.go +++ b/models/user.go @@ -5,10 +5,11 @@ import ( "crypto/sha1" "encoding/hex" "encoding/json" - "github.com/HFO4/cloudreve/pkg/util" + "strings" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" "github.com/pkg/errors" - "strings" ) const ( diff --git a/models/user_authn.go b/models/user_authn.go index d9b2be5..ba329bf 100644 --- a/models/user_authn.go +++ b/models/user_authn.go @@ -5,9 +5,10 @@ import ( "encoding/binary" "encoding/json" "fmt" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/duo-labs/webauthn/webauthn" "net/url" + + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/duo-labs/webauthn/webauthn" ) /* diff --git a/models/user_test.go b/models/user_test.go index 3a241df..ea346a2 100644 --- a/models/user_test.go +++ b/models/user_test.go @@ -2,12 +2,13 @@ package model import ( "encoding/json" + "testing" + "github.com/DATA-DOG/go-sqlmock" - "github.com/HFO4/cloudreve/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/pkg/errors" "github.com/stretchr/testify/assert" - "testing" ) func TestGetUserByID(t *testing.T) { diff --git a/pkg/aria2/aria2.go b/pkg/aria2/aria2.go index 6c2ad58..40ce36a 100644 --- a/pkg/aria2/aria2.go +++ b/pkg/aria2/aria2.go @@ -2,12 +2,13 @@ package aria2 import ( "encoding/json" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "net/url" "sync" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Instance 默认使用的Aria2处理实例 diff --git a/pkg/aria2/aria2_test.go b/pkg/aria2/aria2_test.go index 7992556..51605a1 100644 --- a/pkg/aria2/aria2_test.go +++ b/pkg/aria2/aria2_test.go @@ -2,12 +2,13 @@ package aria2 import ( "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) var mock sqlmock.Sqlmock diff --git a/pkg/aria2/caller.go b/pkg/aria2/caller.go index 5ed2e59..6e287a2 100644 --- a/pkg/aria2/caller.go +++ b/pkg/aria2/caller.go @@ -2,13 +2,14 @@ package aria2 import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/util" "path/filepath" "strconv" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // RPCService 通过RPC服务的Aria2任务管理器 diff --git a/pkg/aria2/caller_test.go b/pkg/aria2/caller_test.go index ca065b8..f215689 100644 --- a/pkg/aria2/caller_test.go +++ b/pkg/aria2/caller_test.go @@ -1,10 +1,11 @@ package aria2 import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/stretchr/testify/assert" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/stretchr/testify/assert" ) func TestRPCService_Init(t *testing.T) { diff --git a/pkg/aria2/monitor.go b/pkg/aria2/monitor.go index eeb9226..bd27f74 100644 --- a/pkg/aria2/monitor.go +++ b/pkg/aria2/monitor.go @@ -4,17 +4,18 @@ import ( "context" "encoding/json" "errors" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/task" - "github.com/HFO4/cloudreve/pkg/util" "os" "path/filepath" "strconv" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/task" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Monitor 离线下载状态监控 diff --git a/pkg/aria2/monitor_test.go b/pkg/aria2/monitor_test.go index c04e89a..9172894 100644 --- a/pkg/aria2/monitor_test.go +++ b/pkg/aria2/monitor_test.go @@ -2,18 +2,19 @@ package aria2 import ( "errors" + "testing" + "time" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/task" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/task" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" testMock "github.com/stretchr/testify/mock" - "testing" - "time" ) type InstanceMock struct { diff --git a/pkg/aria2/notification.go b/pkg/aria2/notification.go index 9eb3c52..e2ead91 100644 --- a/pkg/aria2/notification.go +++ b/pkg/aria2/notification.go @@ -1,8 +1,9 @@ package aria2 import ( - "github.com/HFO4/cloudreve/pkg/aria2/rpc" "sync" + + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" ) // Notifier aria2实践通知处理 diff --git a/pkg/aria2/notification_test.go b/pkg/aria2/notification_test.go index 5b00019..21a7ac1 100644 --- a/pkg/aria2/notification_test.go +++ b/pkg/aria2/notification_test.go @@ -1,9 +1,10 @@ package aria2 import ( - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/stretchr/testify/assert" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/stretchr/testify/assert" ) func TestNotifier_Notify(t *testing.T) { diff --git a/pkg/auth/auth.go b/pkg/auth/auth.go index a0f89b7..86d02c6 100644 --- a/pkg/auth/auth.go +++ b/pkg/auth/auth.go @@ -2,15 +2,16 @@ package auth import ( "bytes" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "io/ioutil" "net/http" "net/url" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) var ( diff --git a/pkg/auth/auth_test.go b/pkg/auth/auth_test.go index 44fba71..1092cb5 100644 --- a/pkg/auth/auth_test.go +++ b/pkg/auth/auth_test.go @@ -1,12 +1,13 @@ package auth import ( - "github.com/HFO4/cloudreve/pkg/util" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "strings" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/stretchr/testify/assert" ) func TestSignURI(t *testing.T) { diff --git a/pkg/auth/hmac_test.go b/pkg/auth/hmac_test.go index 90f55c7..706f617 100644 --- a/pkg/auth/hmac_test.go +++ b/pkg/auth/hmac_test.go @@ -3,15 +3,16 @@ package auth import ( "database/sql" "fmt" + "testing" + "time" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" - "time" ) var mock sqlmock.Sqlmock diff --git a/pkg/authn/auth.go b/pkg/authn/auth.go index ee719e1..5c5b4b7 100644 --- a/pkg/authn/auth.go +++ b/pkg/authn/auth.go @@ -1,7 +1,7 @@ package authn import ( - model "github.com/HFO4/cloudreve/models" + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/duo-labs/webauthn/webauthn" ) diff --git a/pkg/authn/auth_test.go b/pkg/authn/auth_test.go index 036aa53..3df60cf 100644 --- a/pkg/authn/auth_test.go +++ b/pkg/authn/auth_test.go @@ -1,9 +1,10 @@ package authn import ( - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/stretchr/testify/assert" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/stretchr/testify/assert" ) func TestInit(t *testing.T) { diff --git a/pkg/cache/driver.go b/pkg/cache/driver.go index 07d7152..35f6922 100644 --- a/pkg/cache/driver.go +++ b/pkg/cache/driver.go @@ -1,7 +1,7 @@ package cache import ( - "github.com/HFO4/cloudreve/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/gin-gonic/gin" ) diff --git a/pkg/cache/memo.go b/pkg/cache/memo.go index 3b5c366..8b7522b 100644 --- a/pkg/cache/memo.go +++ b/pkg/cache/memo.go @@ -1,9 +1,10 @@ package cache import ( - "github.com/HFO4/cloudreve/pkg/util" "sync" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // MemoStore 内存存储驱动 diff --git a/pkg/cache/redis.go b/pkg/cache/redis.go index de0c45b..c2b9bb7 100644 --- a/pkg/cache/redis.go +++ b/pkg/cache/redis.go @@ -3,10 +3,11 @@ package cache import ( "bytes" "encoding/gob" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gomodule/redigo/redis" "strconv" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gomodule/redigo/redis" ) // RedisStore redis存储驱动 diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 43f2481..c135a50 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -1,7 +1,7 @@ package conf import ( - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/go-ini/ini" "gopkg.in/go-playground/validator.v9" ) @@ -34,7 +34,7 @@ type ssl struct { } type unix struct { - Listen string + Listen string } // slave 作为slave存储端配置 diff --git a/pkg/conf/conf_test.go b/pkg/conf/conf_test.go index 35aeb17..aa95a7e 100644 --- a/pkg/conf/conf_test.go +++ b/pkg/conf/conf_test.go @@ -1,11 +1,12 @@ package conf import ( - "github.com/HFO4/cloudreve/pkg/util" - "github.com/stretchr/testify/assert" "io/ioutil" "os" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/stretchr/testify/assert" ) // 测试Init日志路径错误 diff --git a/pkg/crontab/collect.go b/pkg/crontab/collect.go index 512f8b5..be6798b 100644 --- a/pkg/crontab/collect.go +++ b/pkg/crontab/collect.go @@ -1,13 +1,14 @@ package crontab import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/util" "os" "path/filepath" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) func garbageCollect() { diff --git a/pkg/crontab/init.go b/pkg/crontab/init.go index 78f1756..1b8a322 100644 --- a/pkg/crontab/init.go +++ b/pkg/crontab/init.go @@ -1,8 +1,8 @@ package crontab import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/robfig/cron/v3" ) diff --git a/pkg/email/init.go b/pkg/email/init.go index 65abd75..64771a9 100644 --- a/pkg/email/init.go +++ b/pkg/email/init.go @@ -1,9 +1,10 @@ package email import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" "sync" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Client 默认的邮件发送客户端 diff --git a/pkg/email/smtp.go b/pkg/email/smtp.go index 26946ac..9b77cd9 100644 --- a/pkg/email/smtp.go +++ b/pkg/email/smtp.go @@ -1,9 +1,10 @@ package email import ( - "github.com/HFO4/cloudreve/pkg/util" - "github.com/go-mail/mail" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/go-mail/mail" ) // SMTP SMTP协议发送邮件 diff --git a/pkg/email/template.go b/pkg/email/template.go index 7b25ce3..cb9cb3a 100644 --- a/pkg/email/template.go +++ b/pkg/email/template.go @@ -2,8 +2,9 @@ package email import ( "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // NewActivationEmail 新建激活邮件 diff --git a/pkg/filesystem/archive.go b/pkg/filesystem/archive.go index f867de4..1359e28 100644 --- a/pkg/filesystem/archive.go +++ b/pkg/filesystem/archive.go @@ -5,12 +5,6 @@ import ( "bytes" "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "golang.org/x/text/encoding/simplifiedchinese" - "golang.org/x/text/transform" "io" "io/ioutil" "os" @@ -19,6 +13,13 @@ import ( "strings" "sync" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "golang.org/x/text/encoding/simplifiedchinese" + "golang.org/x/text/transform" ) /* =============== diff --git a/pkg/filesystem/archive_test.go b/pkg/filesystem/archive_test.go index 64c6f5d..7a697ce 100644 --- a/pkg/filesystem/archive_test.go +++ b/pkg/filesystem/archive_test.go @@ -3,19 +3,20 @@ package filesystem import ( "context" "errors" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "os" "strings" "testing" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestFileSystem_Compress(t *testing.T) { diff --git a/pkg/filesystem/driver/cos/handler.go b/pkg/filesystem/driver/cos/handler.go index 6e76a94..008c863 100644 --- a/pkg/filesystem/driver/cos/handler.go +++ b/pkg/filesystem/driver/cos/handler.go @@ -8,13 +8,6 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/google/go-querystring/query" - cossdk "github.com/tencentyun/cos-go-sdk-v5" "io" "net/http" "net/url" @@ -22,6 +15,14 @@ import ( "path/filepath" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/google/go-querystring/query" + cossdk "github.com/tencentyun/cos-go-sdk-v5" ) // UploadPolicy 腾讯云COS上传策略 diff --git a/pkg/filesystem/driver/cos/scf.go b/pkg/filesystem/driver/cos/scf.go index 2874f5a..9ddb29c 100644 --- a/pkg/filesystem/driver/cos/scf.go +++ b/pkg/filesystem/driver/cos/scf.go @@ -4,17 +4,18 @@ import ( "archive/zip" "bytes" "encoding/base64" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" - "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" - scf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416" "io" "io/ioutil" "net/url" "strconv" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" + "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" + scf "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/scf/v20180416" ) const scfFunc = `# -*- coding: utf8 -*- diff --git a/pkg/filesystem/driver/local/handler.go b/pkg/filesystem/driver/local/handler.go index 360e9c2..633150a 100644 --- a/pkg/filesystem/driver/local/handler.go +++ b/pkg/filesystem/driver/local/handler.go @@ -4,18 +4,19 @@ import ( "context" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "io" "net/url" "os" "path/filepath" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Driver 本地策略适配器 diff --git a/pkg/filesystem/driver/local/handler_test.go b/pkg/filesystem/driver/local/handler_test.go index e0c3ddb..2256db7 100644 --- a/pkg/filesystem/driver/local/handler_test.go +++ b/pkg/filesystem/driver/local/handler_test.go @@ -2,19 +2,20 @@ package local import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "io" "io/ioutil" "net/url" "os" "strings" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestHandler_Put(t *testing.T) { diff --git a/pkg/filesystem/driver/onedrive/api.go b/pkg/filesystem/driver/onedrive/api.go index 51d69a1..b791bbf 100644 --- a/pkg/filesystem/driver/onedrive/api.go +++ b/pkg/filesystem/driver/onedrive/api.go @@ -6,11 +6,6 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/util" "io" "io/ioutil" "net/http" @@ -19,6 +14,12 @@ import ( "strconv" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) const ( diff --git a/pkg/filesystem/driver/onedrive/api_test.go b/pkg/filesystem/driver/onedrive/api_test.go index e80c618..62888e8 100644 --- a/pkg/filesystem/driver/onedrive/api_test.go +++ b/pkg/filesystem/driver/onedrive/api_test.go @@ -4,16 +4,17 @@ import ( "context" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io/ioutil" "net/http" "strings" "testing" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestRequest(t *testing.T) { diff --git a/pkg/filesystem/driver/onedrive/client.go b/pkg/filesystem/driver/onedrive/client.go index ccf1512..2767fe2 100644 --- a/pkg/filesystem/driver/onedrive/client.go +++ b/pkg/filesystem/driver/onedrive/client.go @@ -2,8 +2,9 @@ package onedrive import ( "errors" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/request" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/request" ) var ( diff --git a/pkg/filesystem/driver/onedrive/client_test.go b/pkg/filesystem/driver/onedrive/client_test.go index c298a82..aa3c132 100644 --- a/pkg/filesystem/driver/onedrive/client_test.go +++ b/pkg/filesystem/driver/onedrive/client_test.go @@ -1,9 +1,10 @@ package onedrive import ( - model "github.com/HFO4/cloudreve/models" - "github.com/stretchr/testify/assert" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/stretchr/testify/assert" ) func TestNewClient(t *testing.T) { diff --git a/pkg/filesystem/driver/onedrive/handler.go b/pkg/filesystem/driver/onedrive/handler.go index e91ba2f..8afe66a 100644 --- a/pkg/filesystem/driver/onedrive/handler.go +++ b/pkg/filesystem/driver/onedrive/handler.go @@ -4,18 +4,19 @@ import ( "context" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" "io" "net/url" "path" "path/filepath" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // Driver OneDrive 适配器 diff --git a/pkg/filesystem/driver/onedrive/handler_test.go b/pkg/filesystem/driver/onedrive/handler_test.go index ccb5414..a4a5be1 100644 --- a/pkg/filesystem/driver/onedrive/handler_test.go +++ b/pkg/filesystem/driver/onedrive/handler_test.go @@ -2,14 +2,6 @@ package onedrive import ( "context" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" @@ -17,6 +9,15 @@ import ( "strings" "testing" "time" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestDriver_Token(t *testing.T) { diff --git a/pkg/filesystem/driver/onedrive/oauth.go b/pkg/filesystem/driver/onedrive/oauth.go index 28dbd9c..607accd 100644 --- a/pkg/filesystem/driver/onedrive/oauth.go +++ b/pkg/filesystem/driver/onedrive/oauth.go @@ -3,14 +3,15 @@ package onedrive import ( "context" "encoding/json" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/util" "io/ioutil" "net/http" "net/url" "strings" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Error 实现error接口 diff --git a/pkg/filesystem/driver/onedrive/oauth_test.go b/pkg/filesystem/driver/onedrive/oauth_test.go index 33857d8..62243dc 100644 --- a/pkg/filesystem/driver/onedrive/oauth_test.go +++ b/pkg/filesystem/driver/onedrive/oauth_test.go @@ -4,13 +4,6 @@ import ( "context" "database/sql" "errors" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" @@ -18,6 +11,14 @@ import ( "strings" "testing" "time" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) var mock sqlmock.Sqlmock diff --git a/pkg/filesystem/driver/oss/callback.go b/pkg/filesystem/driver/oss/callback.go index dbfc4bc..7ca1e23 100644 --- a/pkg/filesystem/driver/oss/callback.go +++ b/pkg/filesystem/driver/oss/callback.go @@ -10,12 +10,13 @@ import ( "encoding/pem" "errors" "fmt" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/request" "io/ioutil" "net/http" "net/url" "strings" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/request" ) // GetPublicKey 从回调请求或缓存中获取OSS的回调签名公钥 diff --git a/pkg/filesystem/driver/oss/callback_test.go b/pkg/filesystem/driver/oss/callback_test.go index 20c8a2c..1d29341 100644 --- a/pkg/filesystem/driver/oss/callback_test.go +++ b/pkg/filesystem/driver/oss/callback_test.go @@ -1,13 +1,14 @@ package oss import ( - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/url" "strings" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/stretchr/testify/assert" ) func TestGetPublicKey(t *testing.T) { diff --git a/pkg/filesystem/driver/oss/handler.go b/pkg/filesystem/driver/oss/handler.go index 626ba9a..c68e25c 100644 --- a/pkg/filesystem/driver/oss/handler.go +++ b/pkg/filesystem/driver/oss/handler.go @@ -8,19 +8,20 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/aliyun/aliyun-oss-go-sdk/oss" "io" "net/url" "path" "path/filepath" "strings" "time" + + "github.com/aliyun/aliyun-oss-go-sdk/oss" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // UploadPolicy 阿里云OSS上传策略 diff --git a/pkg/filesystem/driver/oss/handler_test.go b/pkg/filesystem/driver/oss/handler_test.go index 5bd83c2..e571d55 100644 --- a/pkg/filesystem/driver/oss/handler_test.go +++ b/pkg/filesystem/driver/oss/handler_test.go @@ -2,18 +2,19 @@ package oss import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" "net/url" "strings" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestDriver_InitOSSClient(t *testing.T) { diff --git a/pkg/filesystem/driver/qiniu/handler.go b/pkg/filesystem/driver/qiniu/handler.go index 355e466..4b24cc5 100644 --- a/pkg/filesystem/driver/qiniu/handler.go +++ b/pkg/filesystem/driver/qiniu/handler.go @@ -4,13 +4,6 @@ import ( "context" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/qiniu/api.v7/v7/auth/qbox" - "github.com/qiniu/api.v7/v7/storage" "io" "net/http" "net/url" @@ -18,6 +11,14 @@ import ( "path/filepath" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/qiniu/api.v7/v7/auth/qbox" + "github.com/qiniu/api.v7/v7/storage" ) // Driver 本地策略适配器 diff --git a/pkg/filesystem/driver/remote/handler.go b/pkg/filesystem/driver/remote/handler.go index 4b584ec..c80e24d 100644 --- a/pkg/filesystem/driver/remote/handler.go +++ b/pkg/filesystem/driver/remote/handler.go @@ -6,18 +6,19 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" "io" "net/http" "net/url" "path" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // Driver 远程存储策略适配器 diff --git a/pkg/filesystem/driver/remote/handler_test.go b/pkg/filesystem/driver/remote/handler_test.go index bf2790b..7ec91dc 100644 --- a/pkg/filesystem/driver/remote/handler_test.go +++ b/pkg/filesystem/driver/remote/handler_test.go @@ -2,20 +2,21 @@ package remote import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" "net/url" "strings" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestHandler_Token(t *testing.T) { diff --git a/pkg/filesystem/driver/s3/handler.go b/pkg/filesystem/driver/s3/handler.go index 4cf44e2..4a4a079 100644 --- a/pkg/filesystem/driver/s3/handler.go +++ b/pkg/filesystem/driver/s3/handler.go @@ -17,16 +17,16 @@ import ( "sync" "time" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // Driver 适配器模板 diff --git a/pkg/filesystem/driver/template/handler.go b/pkg/filesystem/driver/template/handler.go index 165ed93..d6caefd 100644 --- a/pkg/filesystem/driver/template/handler.go +++ b/pkg/filesystem/driver/template/handler.go @@ -3,11 +3,12 @@ package template import ( "context" "errors" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/serializer" "io" "net/url" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // Driver 适配器模板 diff --git a/pkg/filesystem/driver/upyun/handler.go b/pkg/filesystem/driver/upyun/handler.go index 9b4fc19..30fafa5 100644 --- a/pkg/filesystem/driver/upyun/handler.go +++ b/pkg/filesystem/driver/upyun/handler.go @@ -9,12 +9,6 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/upyun/go-sdk/upyun" "io" "net/http" "net/url" @@ -23,6 +17,13 @@ import ( "strings" "sync" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/upyun/go-sdk/upyun" ) // UploadPolicy 又拍云上传策略 diff --git a/pkg/filesystem/errors.go b/pkg/filesystem/errors.go index 56f3d35..a7b8c90 100644 --- a/pkg/filesystem/errors.go +++ b/pkg/filesystem/errors.go @@ -2,7 +2,8 @@ package filesystem import ( "errors" - "github.com/HFO4/cloudreve/pkg/serializer" + + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) var ( diff --git a/pkg/filesystem/file.go b/pkg/filesystem/file.go index deaf98a..efe5101 100644 --- a/pkg/filesystem/file.go +++ b/pkg/filesystem/file.go @@ -2,14 +2,15 @@ package filesystem import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/juju/ratelimit" "io" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/juju/ratelimit" ) /* ============ diff --git a/pkg/filesystem/file_test.go b/pkg/filesystem/file_test.go index efb4c9b..d80cd37 100644 --- a/pkg/filesystem/file_test.go +++ b/pkg/filesystem/file_test.go @@ -2,18 +2,19 @@ package filesystem import ( "context" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "os" "testing" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestFileSystem_AddFile(t *testing.T) { diff --git a/pkg/filesystem/filesystem.go b/pkg/filesystem/filesystem.go index 030f6cf..b6c80e3 100644 --- a/pkg/filesystem/filesystem.go +++ b/pkg/filesystem/filesystem.go @@ -8,20 +8,20 @@ import ( "net/url" "sync" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/cos" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/onedrive" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/oss" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/qiniu" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/remote" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/s3" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/upyun" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/cos" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/oss" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/qiniu" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/remote" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/s3" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/upyun" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" cossdk "github.com/tencentyun/cos-go-sdk-v5" ) diff --git a/pkg/filesystem/filesystem_test.go b/pkg/filesystem/filesystem_test.go index 140024f..6ec56db 100644 --- a/pkg/filesystem/filesystem_test.go +++ b/pkg/filesystem/filesystem_test.go @@ -1,15 +1,16 @@ package filesystem import ( + "net/http/httptest" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/remote" - "github.com/HFO4/cloudreve/pkg/serializer" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/remote" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" - "net/http/httptest" "testing" ) diff --git a/pkg/filesystem/hooks.go b/pkg/filesystem/hooks.go index 1c39ee4..9c6692f 100644 --- a/pkg/filesystem/hooks.go +++ b/pkg/filesystem/hooks.go @@ -3,14 +3,15 @@ package filesystem import ( "context" "errors" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "io/ioutil" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // Hook 钩子函数 diff --git a/pkg/filesystem/hooks_test.go b/pkg/filesystem/hooks_test.go index 9a00265..59fe56b 100644 --- a/pkg/filesystem/hooks_test.go +++ b/pkg/filesystem/hooks_test.go @@ -3,23 +3,24 @@ package filesystem import ( "context" "errors" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" "os" "strings" "testing" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestGenericBeforeUpload(t *testing.T) { diff --git a/pkg/filesystem/image.go b/pkg/filesystem/image.go index 16c1b77..a2e7e08 100644 --- a/pkg/filesystem/image.go +++ b/pkg/filesystem/image.go @@ -3,13 +3,14 @@ package filesystem import ( "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/thumb" - "github.com/HFO4/cloudreve/pkg/util" "strconv" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/thumb" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) /* ================ diff --git a/pkg/filesystem/image_test.go b/pkg/filesystem/image_test.go index eb642fd..0c4d026 100644 --- a/pkg/filesystem/image_test.go +++ b/pkg/filesystem/image_test.go @@ -2,12 +2,13 @@ package filesystem import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/response" + "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" "github.com/stretchr/testify/assert" testMock "github.com/stretchr/testify/mock" - "testing" ) func TestFileSystem_GetThumb(t *testing.T) { diff --git a/pkg/filesystem/manage.go b/pkg/filesystem/manage.go index 9a5a636..ba99571 100644 --- a/pkg/filesystem/manage.go +++ b/pkg/filesystem/manage.go @@ -3,13 +3,14 @@ package filesystem import ( "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "path" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) /* ================= diff --git a/pkg/filesystem/manage_test.go b/pkg/filesystem/manage_test.go index 2d795ce..4156f34 100644 --- a/pkg/filesystem/manage_test.go +++ b/pkg/filesystem/manage_test.go @@ -3,19 +3,20 @@ package filesystem import ( "context" "errors" + "os" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" testMock "github.com/stretchr/testify/mock" - "os" - "testing" ) func TestFileSystem_ListPhysical(t *testing.T) { diff --git a/pkg/filesystem/path.go b/pkg/filesystem/path.go index a57a57e..b0637aa 100644 --- a/pkg/filesystem/path.go +++ b/pkg/filesystem/path.go @@ -1,9 +1,10 @@ package filesystem import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" "path" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) /* ================= diff --git a/pkg/filesystem/path_test.go b/pkg/filesystem/path_test.go index 57d8e6d..e4065a4 100644 --- a/pkg/filesystem/path_test.go +++ b/pkg/filesystem/path_test.go @@ -1,11 +1,12 @@ package filesystem import ( + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestFileSystem_IsFileExist(t *testing.T) { diff --git a/pkg/filesystem/upload.go b/pkg/filesystem/upload.go index 7ca9b0f..2ff8997 100644 --- a/pkg/filesystem/upload.go +++ b/pkg/filesystem/upload.go @@ -2,17 +2,18 @@ package filesystem import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" "io" "os" "path" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" ) /* ================ diff --git a/pkg/filesystem/upload_test.go b/pkg/filesystem/upload_test.go index 8010664..2c0d827 100644 --- a/pkg/filesystem/upload_test.go +++ b/pkg/filesystem/upload_test.go @@ -3,16 +3,6 @@ package filesystem import ( "context" "errors" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/filesystem/response" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" @@ -20,6 +10,17 @@ import ( "net/url" "strings" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/response" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) type FileHeaderMock struct { diff --git a/pkg/filesystem/validator.go b/pkg/filesystem/validator.go index 4288760..1639675 100644 --- a/pkg/filesystem/validator.go +++ b/pkg/filesystem/validator.go @@ -2,9 +2,10 @@ package filesystem import ( "context" - "github.com/HFO4/cloudreve/pkg/util" "path/filepath" "strings" + + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) /* ========== diff --git a/pkg/filesystem/validator_test.go b/pkg/filesystem/validator_test.go index 6e2c078..8a39ae2 100644 --- a/pkg/filesystem/validator_test.go +++ b/pkg/filesystem/validator_test.go @@ -3,12 +3,13 @@ package filesystem import ( "context" "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) var mock sqlmock.Sqlmock diff --git a/pkg/hashid/hash.go b/pkg/hashid/hash.go index ce89b48..942c953 100644 --- a/pkg/hashid/hash.go +++ b/pkg/hashid/hash.go @@ -2,9 +2,10 @@ package hashid import ( "errors" - "github.com/HFO4/cloudreve/pkg/conf" + + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/speps/go-hashids" ) -import "github.com/speps/go-hashids" // ID类型 const ( diff --git a/pkg/request/request.go b/pkg/request/request.go index 80c17e2..36195c8 100644 --- a/pkg/request/request.go +++ b/pkg/request/request.go @@ -5,14 +5,15 @@ import ( "encoding/json" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" "io" "io/ioutil" "net/http" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // GeneralClient 通用 HTTP Client diff --git a/pkg/request/request_test.go b/pkg/request/request_test.go index 0dd8d37..1dac105 100644 --- a/pkg/request/request_test.go +++ b/pkg/request/request_test.go @@ -3,15 +3,16 @@ package request import ( "context" "errors" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io" "io/ioutil" "net/http" "strings" "testing" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) type ClientMock struct { diff --git a/pkg/request/slave.go b/pkg/request/slave.go index 1d52c73..0bd1ca3 100644 --- a/pkg/request/slave.go +++ b/pkg/request/slave.go @@ -4,10 +4,11 @@ import ( "bytes" "encoding/json" "errors" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/serializer" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // RemoteCallback 发送远程存储策略上传回调请求 diff --git a/pkg/request/slave_test.go b/pkg/request/slave_test.go index d97f79e..a7f9fcf 100644 --- a/pkg/request/slave_test.go +++ b/pkg/request/slave_test.go @@ -4,13 +4,14 @@ import ( "bytes" "encoding/json" "errors" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" "io/ioutil" "net/http" "strings" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" ) func TestRemoteCallback(t *testing.T) { diff --git a/pkg/serializer/aria2.go b/pkg/serializer/aria2.go index 0f0ffa0..61afafa 100644 --- a/pkg/serializer/aria2.go +++ b/pkg/serializer/aria2.go @@ -1,9 +1,10 @@ package serializer import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" "path" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" ) // DownloadListResponse 下载列表响应条目 diff --git a/pkg/serializer/aria2_test.go b/pkg/serializer/aria2_test.go index 3f0ad7d..48e7383 100644 --- a/pkg/serializer/aria2_test.go +++ b/pkg/serializer/aria2_test.go @@ -1,12 +1,13 @@ package serializer import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2/rpc" - "github.com/HFO4/cloudreve/pkg/cache" + "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2/rpc" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestBuildFinishedListResponse(t *testing.T) { diff --git a/pkg/serializer/setting.go b/pkg/serializer/setting.go index 1b55afa..c5b310b 100644 --- a/pkg/serializer/setting.go +++ b/pkg/serializer/setting.go @@ -1,6 +1,6 @@ package serializer -import model "github.com/HFO4/cloudreve/models" +import model "github.com/cloudreve/Cloudreve/v3/models" // SiteConfig 站点全局设置序列 type SiteConfig struct { diff --git a/pkg/serializer/setting_test.go b/pkg/serializer/setting_test.go index a286e65..04fb8f6 100644 --- a/pkg/serializer/setting_test.go +++ b/pkg/serializer/setting_test.go @@ -1,10 +1,11 @@ package serializer import ( - model "github.com/HFO4/cloudreve/models" + "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestCheckSettingValue(t *testing.T) { diff --git a/pkg/serializer/share.go b/pkg/serializer/share.go index 2bc7979..9f67704 100644 --- a/pkg/serializer/share.go +++ b/pkg/serializer/share.go @@ -1,9 +1,10 @@ package serializer import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" ) // Share 分享信息序列化 diff --git a/pkg/serializer/share_test.go b/pkg/serializer/share_test.go index f501e14..72feb0c 100644 --- a/pkg/serializer/share_test.go +++ b/pkg/serializer/share_test.go @@ -1,11 +1,12 @@ package serializer import ( - model "github.com/HFO4/cloudreve/models" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "testing" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestBuildShareList(t *testing.T) { diff --git a/pkg/serializer/user.go b/pkg/serializer/user.go index 688ba23..a4f3ed0 100644 --- a/pkg/serializer/user.go +++ b/pkg/serializer/user.go @@ -2,8 +2,9 @@ package serializer import ( "fmt" - "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" "github.com/duo-labs/webauthn/webauthn" ) diff --git a/pkg/serializer/user_test.go b/pkg/serializer/user_test.go index 603175c..cb70fcc 100644 --- a/pkg/serializer/user_test.go +++ b/pkg/serializer/user_test.go @@ -2,13 +2,14 @@ package serializer import ( "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/duo-labs/webauthn/webauthn" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) var mock sqlmock.Sqlmock diff --git a/pkg/task/compress.go b/pkg/task/compress.go index 22934c2..b134922 100644 --- a/pkg/task/compress.go +++ b/pkg/task/compress.go @@ -3,10 +3,11 @@ package task import ( "context" "encoding/json" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/util" "os" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // CompressTask 文件压缩任务 diff --git a/pkg/task/compress_test.go b/pkg/task/compress_test.go index 4c71bc4..681b9fb 100644 --- a/pkg/task/compress_test.go +++ b/pkg/task/compress_test.go @@ -2,13 +2,14 @@ package task import ( "errors" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestCompressTask_Props(t *testing.T) { diff --git a/pkg/task/decompress.go b/pkg/task/decompress.go index ab98fde..5a75871 100644 --- a/pkg/task/decompress.go +++ b/pkg/task/decompress.go @@ -3,8 +3,9 @@ package task import ( "context" "encoding/json" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" ) // DecompressTask 文件压缩任务 diff --git a/pkg/task/decompress_test.go b/pkg/task/decompress_test.go index e5f3713..33887fc 100644 --- a/pkg/task/decompress_test.go +++ b/pkg/task/decompress_test.go @@ -2,11 +2,12 @@ package task import ( "errors" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestDecompressTask_Props(t *testing.T) { diff --git a/pkg/task/import.go b/pkg/task/import.go index 21684d6..45941b1 100644 --- a/pkg/task/import.go +++ b/pkg/task/import.go @@ -3,12 +3,13 @@ package task import ( "context" "encoding/json" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/util" "path" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // ImportTask 导入务 diff --git a/pkg/task/import_test.go b/pkg/task/import_test.go index 21d1d3c..ea22cb8 100644 --- a/pkg/task/import_test.go +++ b/pkg/task/import_test.go @@ -2,13 +2,14 @@ package task import ( "errors" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestImportTask_Props(t *testing.T) { diff --git a/pkg/task/job.go b/pkg/task/job.go index 8f96514..22adc79 100644 --- a/pkg/task/job.go +++ b/pkg/task/job.go @@ -1,8 +1,8 @@ package task import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // 任务类型 diff --git a/pkg/task/job_test.go b/pkg/task/job_test.go index e8e274b..432bbb3 100644 --- a/pkg/task/job_test.go +++ b/pkg/task/job_test.go @@ -2,10 +2,11 @@ package task import ( "errors" - "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/stretchr/testify/assert" "testing" + + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/stretchr/testify/assert" ) func TestRecord(t *testing.T) { diff --git a/pkg/task/pool.go b/pkg/task/pool.go index 4982f90..d44877d 100644 --- a/pkg/task/pool.go +++ b/pkg/task/pool.go @@ -1,8 +1,8 @@ package task import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // TaskPoll 要使用的任务池 diff --git a/pkg/task/pool_test.go b/pkg/task/pool_test.go index 739527f..0ed9641 100644 --- a/pkg/task/pool_test.go +++ b/pkg/task/pool_test.go @@ -2,12 +2,13 @@ package task import ( "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) var mock sqlmock.Sqlmock diff --git a/pkg/task/tranfer.go b/pkg/task/tranfer.go index 7f03df4..80aa124 100644 --- a/pkg/task/tranfer.go +++ b/pkg/task/tranfer.go @@ -3,12 +3,13 @@ package task import ( "context" "encoding/json" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/util" "os" "path" "path/filepath" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) // TransferTask 文件中转任务 diff --git a/pkg/task/transfer_test.go b/pkg/task/transfer_test.go index c31c5ea..a29043a 100644 --- a/pkg/task/transfer_test.go +++ b/pkg/task/transfer_test.go @@ -2,11 +2,12 @@ package task import ( "errors" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/jinzhu/gorm" "github.com/stretchr/testify/assert" - "testing" ) func TestTransferTask_Props(t *testing.T) { diff --git a/pkg/task/worker.go b/pkg/task/worker.go index 980d339..07ef36b 100644 --- a/pkg/task/worker.go +++ b/pkg/task/worker.go @@ -1,6 +1,6 @@ package task -import "github.com/HFO4/cloudreve/pkg/util" +import "github.com/cloudreve/Cloudreve/v3/pkg/util" // Worker 处理任务的对象 type Worker interface { diff --git a/pkg/task/worker_test.go b/pkg/task/worker_test.go index 1f132a5..64c6551 100644 --- a/pkg/task/worker_test.go +++ b/pkg/task/worker_test.go @@ -1,9 +1,10 @@ package task import ( - model "github.com/HFO4/cloudreve/models" - "github.com/stretchr/testify/assert" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/stretchr/testify/assert" ) type MockJob struct { diff --git a/pkg/thumb/image.go b/pkg/thumb/image.go index 4e25f89..3b96ccc 100644 --- a/pkg/thumb/image.go +++ b/pkg/thumb/image.go @@ -3,8 +3,6 @@ package thumb import ( "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/util" "image" "image/gif" "image/jpeg" @@ -13,6 +11,9 @@ import ( "path/filepath" "strings" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/nfnt/resize" ) diff --git a/pkg/thumb/image_test.go b/pkg/thumb/image_test.go index 201f15d..7fe65a1 100644 --- a/pkg/thumb/image_test.go +++ b/pkg/thumb/image_test.go @@ -2,13 +2,14 @@ package thumb import ( "fmt" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/stretchr/testify/assert" "image" "image/jpeg" "os" "testing" + + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/stretchr/testify/assert" ) func CreateTestImage() *os.File { diff --git a/pkg/webdav/file.go b/pkg/webdav/file.go index 983696e..2858776 100644 --- a/pkg/webdav/file.go +++ b/pkg/webdav/file.go @@ -6,11 +6,12 @@ package webdav import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" "net/http" "path" "path/filepath" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" ) // slashClean is equivalent to but slightly more efficient than diff --git a/pkg/webdav/prop.go b/pkg/webdav/prop.go index 636745f..80464e3 100644 --- a/pkg/webdav/prop.go +++ b/pkg/webdav/prop.go @@ -10,10 +10,11 @@ import ( "encoding/xml" "errors" "fmt" - "github.com/HFO4/cloudreve/pkg/filesystem" "net/http" "strconv" "time" + + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" ) type FileInfo interface { diff --git a/pkg/webdav/webdav.go b/pkg/webdav/webdav.go index c859349..a4f9f20 100644 --- a/pkg/webdav/webdav.go +++ b/pkg/webdav/webdav.go @@ -9,17 +9,18 @@ import ( "context" "errors" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/util" "net/http" "net/url" "path" "strconv" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/util" ) type Handler struct { diff --git a/pkg/webdav/xml.go b/pkg/webdav/xml.go index 5d93fb3..34b4f66 100644 --- a/pkg/webdav/xml.go +++ b/pkg/webdav/xml.go @@ -32,7 +32,7 @@ import ( // In the long term, this package should use the standard library's version // only, and the internal fork deleted, once // https://github.com/golang/go/issues/13400 is resolved. - ixml "github.com/HFO4/cloudreve/pkg/webdav/internal/xml" + ixml "github.com/cloudreve/Cloudreve/v3/pkg/webdav/internal/xml" ) // http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockinfo diff --git a/routers/controllers/admin.go b/routers/controllers/admin.go index 3e347db..473cd30 100644 --- a/routers/controllers/admin.go +++ b/routers/controllers/admin.go @@ -1,13 +1,14 @@ package controllers import ( - "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/pkg/email" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/service/admin" - "github.com/gin-gonic/gin" "io" + + "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/pkg/email" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/service/admin" + "github.com/gin-gonic/gin" ) // AdminSummary 获取管理站点概况 diff --git a/routers/controllers/aria2.go b/routers/controllers/aria2.go index 2c6aade..7abe444 100644 --- a/routers/controllers/aria2.go +++ b/routers/controllers/aria2.go @@ -2,9 +2,10 @@ package controllers import ( "context" - ariaCall "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/service/aria2" - "github.com/HFO4/cloudreve/service/explorer" + + ariaCall "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/service/aria2" + "github.com/cloudreve/Cloudreve/v3/service/explorer" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/callback.go b/routers/controllers/callback.go index 69f93bb..56dd1e0 100644 --- a/routers/controllers/callback.go +++ b/routers/controllers/callback.go @@ -4,9 +4,9 @@ import ( "net/url" "strconv" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/service/callback" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/service/callback" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/directory.go b/routers/controllers/directory.go index 74f84f1..a2e0685 100644 --- a/routers/controllers/directory.go +++ b/routers/controllers/directory.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/HFO4/cloudreve/service/explorer" + "github.com/cloudreve/Cloudreve/v3/service/explorer" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/file.go b/routers/controllers/file.go index 92fdf4b..5fb7edb 100644 --- a/routers/controllers/file.go +++ b/routers/controllers/file.go @@ -4,17 +4,18 @@ import "C" import ( "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/service/explorer" - "github.com/gin-gonic/gin" "net/http" "net/url" "strconv" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/service/explorer" + "github.com/gin-gonic/gin" ) func DownloadArchive(c *gin.Context) { diff --git a/routers/controllers/main.go b/routers/controllers/main.go index c104184..1864770 100644 --- a/routers/controllers/main.go +++ b/routers/controllers/main.go @@ -2,8 +2,9 @@ package controllers import ( "encoding/json" - "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" "gopkg.in/go-playground/validator.v9" ) diff --git a/routers/controllers/objects.go b/routers/controllers/objects.go index 267d1e0..8f65d73 100644 --- a/routers/controllers/objects.go +++ b/routers/controllers/objects.go @@ -2,7 +2,8 @@ package controllers import ( "context" - "github.com/HFO4/cloudreve/service/explorer" + + "github.com/cloudreve/Cloudreve/v3/service/explorer" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/share.go b/routers/controllers/share.go index bdc7d1e..10e8980 100644 --- a/routers/controllers/share.go +++ b/routers/controllers/share.go @@ -2,13 +2,14 @@ package controllers import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/service/share" - "github.com/gin-gonic/gin" "path" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/service/share" + "github.com/gin-gonic/gin" ) // CreateShare 创建分享 diff --git a/routers/controllers/site.go b/routers/controllers/site.go index 8b592dd..8de9707 100644 --- a/routers/controllers/site.go +++ b/routers/controllers/site.go @@ -1,10 +1,10 @@ package controllers import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" "github.com/mojocn/base64Captcha" ) diff --git a/routers/controllers/slave.go b/routers/controllers/slave.go index 29c115a..4f7a98a 100644 --- a/routers/controllers/slave.go +++ b/routers/controllers/slave.go @@ -2,15 +2,16 @@ package controllers import ( "context" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/service/admin" - "github.com/HFO4/cloudreve/service/explorer" - "github.com/gin-gonic/gin" "net/url" "strconv" + + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/service/admin" + "github.com/cloudreve/Cloudreve/v3/service/explorer" + "github.com/gin-gonic/gin" ) // SlaveUpload 从机文件上传 diff --git a/routers/controllers/tag.go b/routers/controllers/tag.go index 5f67f3f..341841b 100644 --- a/routers/controllers/tag.go +++ b/routers/controllers/tag.go @@ -1,7 +1,7 @@ package controllers import ( - "github.com/HFO4/cloudreve/service/explorer" + "github.com/cloudreve/Cloudreve/v3/service/explorer" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/user.go b/routers/controllers/user.go index 818dff5..bbbf925 100644 --- a/routers/controllers/user.go +++ b/routers/controllers/user.go @@ -3,13 +3,14 @@ package controllers import ( "encoding/json" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/authn" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/thumb" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/service/user" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/authn" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/thumb" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/service/user" "github.com/duo-labs/webauthn/webauthn" "github.com/gin-gonic/gin" ) diff --git a/routers/controllers/webdav.go b/routers/controllers/webdav.go index 48e91c3..daf10e7 100644 --- a/routers/controllers/webdav.go +++ b/routers/controllers/webdav.go @@ -1,11 +1,11 @@ package controllers import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/pkg/webdav" - "github.com/HFO4/cloudreve/service/setting" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/webdav" + "github.com/cloudreve/Cloudreve/v3/service/setting" "github.com/gin-gonic/gin" ) diff --git a/routers/file_router_test.go b/routers/file_router_test.go index 8d9f76f..50104b7 100644 --- a/routers/file_router_test.go +++ b/routers/file_router_test.go @@ -3,15 +3,16 @@ package routers import ( "bytes" "encoding/json" - "github.com/HFO4/cloudreve/middleware" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/service/explorer" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "strings" "testing" + + "github.com/cloudreve/Cloudreve/v3/middleware" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/service/explorer" + "github.com/stretchr/testify/assert" ) func TestListDirectoryRoute(t *testing.T) { diff --git a/routers/main_test.go b/routers/main_test.go index 6182242..83664bd 100644 --- a/routers/main_test.go +++ b/routers/main_test.go @@ -2,11 +2,12 @@ package routers import ( "database/sql" + "testing" + "github.com/DATA-DOG/go-sqlmock" - model "github.com/HFO4/cloudreve/models" + model "github.com/cloudreve/Cloudreve/v3/models" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" - "testing" ) var mock sqlmock.Sqlmock diff --git a/routers/router.go b/routers/router.go index 71a3d57..73243f5 100644 --- a/routers/router.go +++ b/routers/router.go @@ -1,12 +1,12 @@ package routers import ( - "github.com/HFO4/cloudreve/bootstrap" - "github.com/HFO4/cloudreve/middleware" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/routers/controllers" + "github.com/cloudreve/Cloudreve/v3/bootstrap" + "github.com/cloudreve/Cloudreve/v3/middleware" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/routers/controllers" "github.com/gin-contrib/cors" "github.com/gin-contrib/gzip" "github.com/gin-contrib/static" diff --git a/routers/router_test.go b/routers/router_test.go index 28b3746..4c65d4e 100644 --- a/routers/router_test.go +++ b/routers/router_test.go @@ -1,12 +1,13 @@ package routers import ( - "github.com/HFO4/cloudreve/models" - "github.com/jinzhu/gorm" - "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "testing" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" ) func TestPing(t *testing.T) { diff --git a/service/admin/aria2.go b/service/admin/aria2.go index 358efac..8801c96 100644 --- a/service/admin/aria2.go +++ b/service/admin/aria2.go @@ -1,9 +1,10 @@ package admin import ( - "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/pkg/serializer" "net/url" + + "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // Aria2TestService aria2连接测试服务 diff --git a/service/admin/file.go b/service/admin/file.go index a08a3fa..bf9bd18 100644 --- a/service/admin/file.go +++ b/service/admin/file.go @@ -2,13 +2,14 @@ package admin import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/service/explorer" - "github.com/gin-gonic/gin" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/service/explorer" + "github.com/gin-gonic/gin" ) // FileService 文件ID服务 diff --git a/service/admin/group.go b/service/admin/group.go index 0968b3a..c761611 100644 --- a/service/admin/group.go +++ b/service/admin/group.go @@ -2,8 +2,9 @@ package admin import ( "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // AddGroupService 用户组添加服务 diff --git a/service/admin/list.go b/service/admin/list.go index b8a0141..bd84e35 100644 --- a/service/admin/list.go +++ b/service/admin/list.go @@ -1,8 +1,8 @@ package admin import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // AdminListService 仪表盘列条目服务 diff --git a/service/admin/policy.go b/service/admin/policy.go index c066d7f..7cd55fd 100644 --- a/service/admin/policy.go +++ b/service/admin/policy.go @@ -12,17 +12,17 @@ import ( "strings" "time" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/cos" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/onedrive" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/oss" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/s3" - "github.com/HFO4/cloudreve/pkg/request" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/cos" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/oss" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/s3" + "github.com/cloudreve/Cloudreve/v3/pkg/request" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" cossdk "github.com/tencentyun/cos-go-sdk-v5" ) diff --git a/service/admin/share.go b/service/admin/share.go index 12d3d4f..5846bb2 100644 --- a/service/admin/share.go +++ b/service/admin/share.go @@ -1,11 +1,12 @@ package admin import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" ) // ShareBatchService 分享批量操作服务 diff --git a/service/admin/site.go b/service/admin/site.go index c611987..fd1177a 100644 --- a/service/admin/site.go +++ b/service/admin/site.go @@ -1,12 +1,13 @@ package admin import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/conf" - "github.com/HFO4/cloudreve/pkg/email" - "github.com/HFO4/cloudreve/pkg/serializer" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/conf" + "github.com/cloudreve/Cloudreve/v3/pkg/email" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // NoParamService 无需参数的服务 diff --git a/service/admin/task.go b/service/admin/task.go index a6a9b34..6b0f861 100644 --- a/service/admin/task.go +++ b/service/admin/task.go @@ -1,11 +1,12 @@ package admin import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/task" - "github.com/gin-gonic/gin" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/task" + "github.com/gin-gonic/gin" ) // TaskBatchService 任务批量操作服务 diff --git a/service/admin/user.go b/service/admin/user.go index 124ba79..f4a58a9 100644 --- a/service/admin/user.go +++ b/service/admin/user.go @@ -2,10 +2,11 @@ package admin import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/serializer" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" ) // AddUserService 用户添加服务 diff --git a/service/aria2/add.go b/service/aria2/add.go index 8f552a2..be7213a 100644 --- a/service/aria2/add.go +++ b/service/aria2/add.go @@ -1,10 +1,10 @@ package aria2 import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/serializer" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" ) diff --git a/service/aria2/manage.go b/service/aria2/manage.go index 4d3ab7d..1da3e05 100644 --- a/service/aria2/manage.go +++ b/service/aria2/manage.go @@ -1,9 +1,9 @@ package aria2 import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/aria2" - "github.com/HFO4/cloudreve/pkg/serializer" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/aria2" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" ) diff --git a/service/callback/oauth.go b/service/callback/oauth.go index 9f124c7..1515f99 100644 --- a/service/callback/oauth.go +++ b/service/callback/oauth.go @@ -2,11 +2,12 @@ package callback import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/onedrive" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) diff --git a/service/callback/upload.go b/service/callback/upload.go index e9894d5..5ccf79a 100644 --- a/service/callback/upload.go +++ b/service/callback/upload.go @@ -5,14 +5,14 @@ import ( "fmt" "strings" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/cos" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/onedrive" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/s3" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/cos" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/onedrive" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/s3" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) diff --git a/service/explorer/directory.go b/service/explorer/directory.go index fffc585..0291ba5 100644 --- a/service/explorer/directory.go +++ b/service/explorer/directory.go @@ -2,9 +2,10 @@ package explorer import ( "context" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" + + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" ) diff --git a/service/explorer/file.go b/service/explorer/file.go index 164fbfe..1015b98 100644 --- a/service/explorer/file.go +++ b/service/explorer/file.go @@ -5,14 +5,6 @@ import ( "encoding/base64" "encoding/json" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/driver/local" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" - "github.com/jinzhu/gorm" "io/ioutil" "net/http" "net/url" @@ -20,6 +12,15 @@ import ( "strconv" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/driver/local" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" + "github.com/jinzhu/gorm" ) // SingleFileService 对单文件进行操作的五福,path为文件完整路径 diff --git a/service/explorer/objects.go b/service/explorer/objects.go index 6275136..e090a2c 100644 --- a/service/explorer/objects.go +++ b/service/explorer/objects.go @@ -3,21 +3,22 @@ package explorer import ( "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/task" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" "math" "net/url" "path" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/task" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" ) // ItemMoveService 处理多文件/目录移动 diff --git a/service/explorer/search.go b/service/explorer/search.go index 4cb62fd..5e661f9 100644 --- a/service/explorer/search.go +++ b/service/explorer/search.go @@ -2,12 +2,13 @@ package explorer import ( "context" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" ) // ItemSearchService 文件搜索服务 diff --git a/service/explorer/tag.go b/service/explorer/tag.go index 4accb08..ffada1c 100644 --- a/service/explorer/tag.go +++ b/service/explorer/tag.go @@ -2,11 +2,12 @@ package explorer import ( "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" "strings" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" ) // FilterTagCreateService 文件分类标签创建服务 diff --git a/service/explorer/upload.go b/service/explorer/upload.go index 8b219ef..4495461 100644 --- a/service/explorer/upload.go +++ b/service/explorer/upload.go @@ -2,9 +2,10 @@ package explorer import ( "context" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/serializer" + + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" "github.com/gin-gonic/gin" ) diff --git a/service/setting/webdav.go b/service/setting/webdav.go index 7e1931c..f2d7e8f 100644 --- a/service/setting/webdav.go +++ b/service/setting/webdav.go @@ -1,9 +1,9 @@ package setting import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) diff --git a/service/share/manage.go b/service/share/manage.go index a9c1d47..6f4c739 100644 --- a/service/share/manage.go +++ b/service/share/manage.go @@ -1,12 +1,13 @@ package share import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/gin-gonic/gin" "net/url" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/gin-gonic/gin" ) // ShareCreateService 创建新分享服务 diff --git a/service/share/visit.go b/service/share/visit.go index 03c64a3..0eb0c8e 100644 --- a/service/share/visit.go +++ b/service/share/visit.go @@ -3,16 +3,17 @@ package share import ( "context" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/filesystem" - "github.com/HFO4/cloudreve/pkg/filesystem/fsctx" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/HFO4/cloudreve/service/explorer" - "github.com/gin-gonic/gin" "net/http" "path" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" + "github.com/cloudreve/Cloudreve/v3/pkg/filesystem/fsctx" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/cloudreve/Cloudreve/v3/service/explorer" + "github.com/gin-gonic/gin" ) // ShareUserGetService 获取用户的分享服务 diff --git a/service/user/login.go b/service/user/login.go index f9ebd98..6c2262e 100644 --- a/service/user/login.go +++ b/service/user/login.go @@ -2,19 +2,20 @@ package user import ( "fmt" - "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/cache" - "github.com/HFO4/cloudreve/pkg/email" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/recaptcha" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/mojocn/base64Captcha" - "github.com/pquerna/otp/totp" "net/url" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/email" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/recaptcha" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/mojocn/base64Captcha" + "github.com/pquerna/otp/totp" ) // UserLoginService 管理用户登录的服务 diff --git a/service/user/register.go b/service/user/register.go index a69ac7a..c968ba6 100644 --- a/service/user/register.go +++ b/service/user/register.go @@ -1,18 +1,19 @@ package user import ( - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/auth" - "github.com/HFO4/cloudreve/pkg/email" - "github.com/HFO4/cloudreve/pkg/hashid" - "github.com/HFO4/cloudreve/pkg/recaptcha" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/mojocn/base64Captcha" "net/url" "strings" "time" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/auth" + "github.com/cloudreve/Cloudreve/v3/pkg/email" + "github.com/cloudreve/Cloudreve/v3/pkg/hashid" + "github.com/cloudreve/Cloudreve/v3/pkg/recaptcha" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/mojocn/base64Captcha" ) // UserRegisterService 管理用户注册的服务 diff --git a/service/user/setting.go b/service/user/setting.go index 4e1a02a..7561320 100644 --- a/service/user/setting.go +++ b/service/user/setting.go @@ -3,15 +3,16 @@ package user import ( "crypto/md5" "fmt" - model "github.com/HFO4/cloudreve/models" - "github.com/HFO4/cloudreve/pkg/serializer" - "github.com/HFO4/cloudreve/pkg/util" - "github.com/gin-gonic/gin" - "github.com/pquerna/otp/totp" "net/http" "net/url" "os" "path/filepath" + + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/serializer" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/pquerna/otp/totp" ) // SettingService 通用设置服务 From d97bc26042589c2530d8335f28cdf48c6195f934 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sat, 21 Nov 2020 19:32:25 +0800 Subject: [PATCH 11/34] Fix: add recycleLock preventing recycle FileSystem used by another goroutine --- assets | 2 +- pkg/filesystem/filesystem.go | 5 +++++ pkg/filesystem/hooks.go | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/assets b/assets index 8ec4514..253bf0c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8ec4514b7690eef20b283c1f00ee2d921f19ae7d +Subproject commit 253bf0c5a064345af2ba4e5c3df68978de49755b diff --git a/pkg/filesystem/filesystem.go b/pkg/filesystem/filesystem.go index b6c80e3..af62983 100644 --- a/pkg/filesystem/filesystem.go +++ b/pkg/filesystem/filesystem.go @@ -97,6 +97,9 @@ type FileSystem struct { 文件系统处理适配器 */ Handler Handler + + // 回收锁 + recycleLock sync.Mutex } // getEmptyFS 从pool中获取新的FileSystem @@ -107,6 +110,7 @@ func getEmptyFS() *FileSystem { // Recycle 回收FileSystem资源 func (fs *FileSystem) Recycle() { + fs.recycleLock.Lock() fs.reset() FSPool.Put(fs) } @@ -120,6 +124,7 @@ func (fs *FileSystem) reset() { fs.Handler = nil fs.Root = nil fs.Lock = sync.Mutex{} + fs.recycleLock = sync.Mutex{} } // NewFileSystem 初始化一个文件系统 diff --git a/pkg/filesystem/hooks.go b/pkg/filesystem/hooks.go index 9c6692f..eb8bbed 100644 --- a/pkg/filesystem/hooks.go +++ b/pkg/filesystem/hooks.go @@ -228,7 +228,9 @@ func GenericAfterUpdate(ctx context.Context, fs *FileSystem) error { // 尝试清空原有缩略图并重新生成 if originFile.GetPolicy().IsThumbGenerateNeeded() { + fs.recycleLock.Lock() go func() { + defer fs.recycleLock.Unlock() if originFile.PicInfo != "" { _, _ = fs.Handler.Delete(ctx, []string{originFile.SourceName + conf.ThumbConfig.FileSuffix}) fs.GenerateThumbnail(ctx, &originFile) @@ -297,7 +299,11 @@ func GenericAfterUpload(ctx context.Context, fs *FileSystem) error { // 异步尝试生成缩略图 if fs.User.Policy.IsThumbGenerateNeeded() { - go fs.GenerateThumbnail(ctx, file) + fs.recycleLock.Lock() + go func() { + defer fs.recycleLock.Unlock() + fs.GenerateThumbnail(ctx, file) + }() } return nil From c6110e9e75146fe555b63068fc224084629dd1b4 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 23 Nov 2020 18:44:13 +0800 Subject: [PATCH 12/34] Feat: keep folder structure in aria2 transferring --- pkg/aria2/monitor.go | 1 + pkg/task/tranfer.go | 25 +++++++++++++++++++------ pkg/task/transfer_test.go | 29 +++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/pkg/aria2/monitor.go b/pkg/aria2/monitor.go index bd27f74..1667f47 100644 --- a/pkg/aria2/monitor.go +++ b/pkg/aria2/monitor.go @@ -251,6 +251,7 @@ func (monitor *Monitor) Complete(status rpc.StatusInfo) bool { file, monitor.Task.Dst, monitor.Task.Parent, + true, ) if err != nil { monitor.setErrorStatus(err) diff --git a/pkg/task/tranfer.go b/pkg/task/tranfer.go index 80aa124..79e84ac 100644 --- a/pkg/task/tranfer.go +++ b/pkg/task/tranfer.go @@ -6,6 +6,7 @@ import ( "os" "path" "path/filepath" + "strings" model "github.com/cloudreve/Cloudreve/v3/models" "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" @@ -24,9 +25,11 @@ type TransferTask struct { // TransferProps 中转任务属性 type TransferProps struct { - Src []string `json:"src"` // 原始目录 + Src []string `json:"src"` // 原始文件 Parent string `json:"parent"` // 父目录 Dst string `json:"dst"` // 目的目录ID + // 将会保留原始文件的目录结构,Src 除去 Parent 开头作为最终路径 + TrimPath bool `json:"trim_path"` } // Props 获取任务属性 @@ -90,7 +93,16 @@ func (job *TransferTask) Do() { for index, file := range job.TaskProps.Src { job.TaskModel.SetProgress(index) - err = fs.UploadFromPath(context.Background(), file, path.Join(job.TaskProps.Dst, filepath.Base(file))) + + dst := path.Join(job.TaskProps.Dst, filepath.Base(file)) + if job.TaskProps.TrimPath { + // 保留原始目录 + trim := util.FormSlash(job.TaskProps.Parent) + src := util.FormSlash(file) + dst = path.Join(job.TaskProps.Dst, strings.TrimPrefix(src, trim)) + } + + err = fs.UploadFromPath(context.Background(), file, dst) if err != nil { job.SetErrorMsg("文件转存失败", err) } @@ -108,7 +120,7 @@ func (job *TransferTask) Recycle() { } // NewTransferTask 新建中转任务 -func NewTransferTask(user uint, src []string, dst, parent string) (Job, error) { +func NewTransferTask(user uint, src []string, dst, parent string, trim bool) (Job, error) { creator, err := model.GetActiveUserByID(user) if err != nil { return nil, err @@ -117,9 +129,10 @@ func NewTransferTask(user uint, src []string, dst, parent string) (Job, error) { newTask := &TransferTask{ User: &creator, TaskProps: TransferProps{ - Src: src, - Parent: parent, - Dst: dst, + Src: src, + Parent: parent, + Dst: dst, + TrimPath: trim, }, } diff --git a/pkg/task/transfer_test.go b/pkg/task/transfer_test.go index a29043a..5d2c9c5 100644 --- a/pkg/task/transfer_test.go +++ b/pkg/task/transfer_test.go @@ -102,6 +102,31 @@ func TestTransferTask_Do(t *testing.T) { asserts.NoError(mock.ExpectationsWereMet()) asserts.NotEmpty(task.GetError().Msg) } + + // 替换目录前缀 + { + task.User = &model.User{ + Policy: model.Policy{ + Type: "mock", + }, + } + task.TaskProps.Src = []string{"test/not_exist"} + task.TaskProps.Parent = "test/not_exist" + task.TaskProps.TrimPath = true + // 更新进度 + mock.ExpectBegin() + mock.ExpectExec("UPDATE(.+)").WillReturnResult(sqlmock.NewResult(1, + 1)) + mock.ExpectCommit() + // 更新错误 + mock.ExpectBegin() + mock.ExpectExec("UPDATE(.+)").WillReturnResult(sqlmock.NewResult(1, + 1)) + mock.ExpectCommit() + task.Do() + asserts.NoError(mock.ExpectationsWereMet()) + asserts.NotEmpty(task.GetError().Msg) + } } func TestNewTransferTask(t *testing.T) { @@ -113,7 +138,7 @@ func TestNewTransferTask(t *testing.T) { mock.ExpectBegin() mock.ExpectExec("INSERT(.+)").WillReturnResult(sqlmock.NewResult(1, 1)) mock.ExpectCommit() - job, err := NewTransferTask(1, []string{}, "/", "/") + job, err := NewTransferTask(1, []string{}, "/", "/", false) asserts.NoError(mock.ExpectationsWereMet()) asserts.NotNil(job) asserts.NoError(err) @@ -125,7 +150,7 @@ func TestNewTransferTask(t *testing.T) { mock.ExpectBegin() mock.ExpectExec("INSERT(.+)").WillReturnError(errors.New("error")) mock.ExpectRollback() - job, err := NewTransferTask(1, []string{}, "/", "/") + job, err := NewTransferTask(1, []string{}, "/", "/", false) asserts.NoError(mock.ExpectationsWereMet()) asserts.Nil(job) asserts.Error(err) From f0a68236a8a724a17a16486aed817f18d93e347e Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Mon, 23 Nov 2020 19:24:56 +0800 Subject: [PATCH 13/34] Feat: delete aria2 record in client side (#335) --- assets | 2 +- models/download.go | 5 +++++ models/download_test.go | 16 ++++++++++++++++ pkg/serializer/aria2.go | 2 ++ routers/controllers/aria2.go | 2 +- routers/router.go | 2 +- service/aria2/manage.go | 10 +++++++--- 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/assets b/assets index 253bf0c..1a2f8ce 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 253bf0c5a064345af2ba4e5c3df68978de49755b +Subproject commit 1a2f8ce8ca7346b4b1822a7f4dd84bef70db71de diff --git a/models/download.go b/models/download.go index e73ae5f..edafb1c 100644 --- a/models/download.go +++ b/models/download.go @@ -109,3 +109,8 @@ func (task *Download) GetOwner() *User { } return task.User } + +// Delete 删除离线下载记录 +func (download *Download) Delete() error { + return DB.Model(download).Delete(download).Error +} diff --git a/models/download_test.go b/models/download_test.go index 7be81d0..9d9cd34 100644 --- a/models/download_test.go +++ b/models/download_test.go @@ -161,3 +161,19 @@ func TestGetDownloadsByStatusAndUser(t *testing.T) { asserts.Len(res, 2) } } + +func TestDownload_Delete(t *testing.T) { + asserts := assert.New(t) + share := Download{} + + { + mock.ExpectBegin() + mock.ExpectExec("UPDATE(.+)"). + WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectCommit() + err := share.Delete() + asserts.NoError(mock.ExpectationsWereMet()) + asserts.NoError(err) + } + +} diff --git a/pkg/serializer/aria2.go b/pkg/serializer/aria2.go index 61afafa..d9eea54 100644 --- a/pkg/serializer/aria2.go +++ b/pkg/serializer/aria2.go @@ -23,6 +23,7 @@ type DownloadListResponse struct { // FinishedListResponse 已完成任务条目 type FinishedListResponse struct { Name string `json:"name"` + GID string `json:"gid"` Status int `json:"status"` Dst string `json:"dst"` Error string `json:"error"` @@ -51,6 +52,7 @@ func BuildFinishedListResponse(tasks []model.Download) Response { download := FinishedListResponse{ Name: fileName, + GID: tasks[i].GID, Status: tasks[i].Status, Error: tasks[i].Error, Dst: tasks[i].Dst, diff --git a/routers/controllers/aria2.go b/routers/controllers/aria2.go index 7abe444..b2bc6d6 100644 --- a/routers/controllers/aria2.go +++ b/routers/controllers/aria2.go @@ -63,7 +63,7 @@ func AddAria2Torrent(c *gin.Context) { } } -// CancelAria2Download 取消aria2离线下载任务 +// CancelAria2Download 取消或删除aria2离线下载任务 func CancelAria2Download(c *gin.Context) { var selectService aria2.DownloadTaskService if err := c.ShouldBindUri(&selectService); err == nil { diff --git a/routers/router.go b/routers/router.go index 73243f5..baf5253 100644 --- a/routers/router.go +++ b/routers/router.go @@ -485,7 +485,7 @@ func InitMasterRouter() *gin.Engine { aria2.POST("torrent/:id", middleware.HashID(hashid.FileID), controllers.AddAria2Torrent) // 重新选择要下载的文件 aria2.PUT("select/:gid", controllers.SelectAria2File) - // 取消下载任务 + // 取消或删除下载任务 aria2.DELETE("task/:gid", controllers.CancelAria2Download) // 获取正在下载中的任务 aria2.GET("downloading", controllers.ListDownloading) diff --git a/service/aria2/manage.go b/service/aria2/manage.go index 1da3e05..d93bbca 100644 --- a/service/aria2/manage.go +++ b/service/aria2/manage.go @@ -36,7 +36,7 @@ func (service *DownloadListService) Downloading(c *gin.Context, user *model.User return serializer.BuildDownloadingResponse(downloads) } -// Delete 取消下载任务 +// Delete 取消或删除下载任务 func (service *DownloadTaskService) Delete(c *gin.Context) serializer.Response { userCtx, _ := c.Get("user") user := userCtx.(*model.User) @@ -47,8 +47,12 @@ func (service *DownloadTaskService) Delete(c *gin.Context) serializer.Response { return serializer.Err(serializer.CodeNotFound, "下载记录不存在", err) } - if download.Status != aria2.Downloading && download.Status != aria2.Paused { - return serializer.Err(serializer.CodeNoPermissionErr, "此下载任务无法取消", err) + if download.Status >= aria2.Error { + // 如果任务已完成,则删除任务记录 + if err := download.Delete(); err != nil { + return serializer.Err(serializer.CodeDBError, "任务记录删除失败", err) + } + return serializer.Response{} } // 取消任务 From 0d210e87b31679fcd161628690c8318bb60d3701 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 24 Nov 2020 18:47:44 +0800 Subject: [PATCH 14/34] Fix: aria2 task failed due to limited size of attr filed in DB --- models/download.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/download.go b/models/download.go index edafb1c..12b2e57 100644 --- a/models/download.go +++ b/models/download.go @@ -18,10 +18,10 @@ type Download struct { DownloadedSize uint64 // 文件大小 GID string `gorm:"size:32,index:gid"` // 任务ID Speed int // 下载速度 - Parent string `gorm:"type:text"` // 存储目录 - Attrs string `gorm:"type:text"` // 任务状态属性 - Error string `gorm:"type:text"` // 错误描述 - Dst string `gorm:"type:text"` // 用户文件系统存储父目录路径 + Parent string `gorm:"type:text"` // 存储目录 + Attrs string `gorm:"type:text,size:65535"` // 任务状态属性 + Error string `gorm:"type:text"` // 错误描述 + Dst string `gorm:"type:text"` // 用户文件系统存储父目录路径 UserID uint // 发起者UID TaskID uint // 对应的转存任务ID From ae89b402f63a8955d6d6415a56cee737bd0be233 Mon Sep 17 00:00:00 2001 From: Archerx Date: Wed, 25 Nov 2020 21:23:26 +0800 Subject: [PATCH 15/34] fix: statik data needs to be initialized (#640) Co-authored-by: xuc2 --- bootstrap/static.go | 1 + 1 file changed, 1 insertion(+) diff --git a/bootstrap/static.go b/bootstrap/static.go index 7b8a987..09e393d 100644 --- a/bootstrap/static.go +++ b/bootstrap/static.go @@ -9,6 +9,7 @@ import ( "github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/cloudreve/Cloudreve/v3/pkg/util" + _ "github.com/cloudreve/Cloudreve/v3/statik" "github.com/gin-contrib/static" "github.com/rakyll/statik/fs" ) From a5805b022a9da9b25853178adae112fcab62a277 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 29 Nov 2020 19:15:35 +0800 Subject: [PATCH 16/34] Feat: enable using LAN endpoint in serverside request of OSS policy (#399) --- assets | 2 +- models/policy.go | 4 ++-- pkg/filesystem/driver/oss/handler.go | 29 ++++++++++++++++------- pkg/filesystem/driver/oss/handler_test.go | 23 ++++++++++++++++-- pkg/filesystem/fsctx/context.go | 2 ++ 5 files changed, 47 insertions(+), 13 deletions(-) diff --git a/assets b/assets index 1a2f8ce..1bd0933 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1a2f8ce8ca7346b4b1822a7f4dd84bef70db71de +Subproject commit 1bd093315526ac8585a8c7a3499e50f2a13d82fa diff --git a/models/policy.go b/models/policy.go index 7c0dee4..34d6a2b 100644 --- a/models/policy.go +++ b/models/policy.go @@ -47,12 +47,12 @@ type PolicyOption struct { FileType []string `json:"file_type"` // MimeType MimeType string `json:"mimetype"` - // OdRedirect Onedrive重定向地址 OdRedirect string `json:"od_redirect,omitempty"` - // Region 区域代码 Region string `json:"region,omitempty"` + // ServerSideEndpoint 服务端请求使用的 Endpoint,为空时使用 Policy.Server 字段 + ServerSideEndpoint string `json:"server_side_endpoint,omitempty"` } var thumbSuffix = map[string][]string{ diff --git a/pkg/filesystem/driver/oss/handler.go b/pkg/filesystem/driver/oss/handler.go index c68e25c..9dd5353 100644 --- a/pkg/filesystem/driver/oss/handler.go +++ b/pkg/filesystem/driver/oss/handler.go @@ -55,7 +55,7 @@ const ( // CORS 创建跨域策略 func (handler *Driver) CORS() error { // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + if err := handler.InitOSSClient(false); err != nil { return err } @@ -77,14 +77,20 @@ func (handler *Driver) CORS() error { } // InitOSSClient 初始化OSS鉴权客户端 -func (handler *Driver) InitOSSClient() error { +func (handler *Driver) InitOSSClient(forceUsePublicEndpoint bool) error { if handler.Policy == nil { return errors.New("存储策略为空") } if handler.client == nil { + // 决定是否使用内网 Endpoint + endpoint := handler.Policy.Server + if handler.Policy.OptionsSerialized.ServerSideEndpoint != "" && !forceUsePublicEndpoint { + endpoint = handler.Policy.OptionsSerialized.ServerSideEndpoint + } + // 初始化客户端 - client, err := oss.New(handler.Policy.Server, handler.Policy.AccessKey, handler.Policy.SecretKey) + client, err := oss.New(endpoint, handler.Policy.AccessKey, handler.Policy.SecretKey) if err != nil { return err } @@ -105,7 +111,7 @@ func (handler *Driver) InitOSSClient() error { // List 列出OSS上的文件 func (handler Driver) List(ctx context.Context, base string, recursive bool) ([]response.Object, error) { // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + if err := handler.InitOSSClient(false); err != nil { return nil, err } @@ -179,6 +185,9 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, // 通过VersionID禁止缓存 ctx = context.WithValue(ctx, VersionID, time.Now().UnixNano()) + // 尽可能使用私有 Endpoint + ctx = context.WithValue(ctx, fsctx.ForceUsePublicEndpoint, false) + // 获取文件源地址 downloadURL, err := handler.Source( ctx, @@ -219,7 +228,7 @@ func (handler Driver) Put(ctx context.Context, file io.ReadCloser, dst string, s defer file.Close() // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + if err := handler.InitOSSClient(false); err != nil { return err } @@ -243,7 +252,7 @@ func (handler Driver) Put(ctx context.Context, file io.ReadCloser, dst string, s // 返回未删除的文件 func (handler Driver) Delete(ctx context.Context, files []string) ([]string, error) { // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + if err := handler.InitOSSClient(false); err != nil { return files, err } @@ -266,7 +275,7 @@ func (handler Driver) Delete(ctx context.Context, files []string) ([]string, err // Thumb 获取文件缩略图 func (handler Driver) Thumb(ctx context.Context, path string) (*response.ContentResponse, error) { // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + if err := handler.InitOSSClient(true); err != nil { return nil, err } @@ -307,7 +316,11 @@ func (handler Driver) Source( speed int, ) (string, error) { // 初始化客户端 - if err := handler.InitOSSClient(); err != nil { + usePublicEndpoint := true + if forceUsePublicEndpoint, ok := ctx.Value(fsctx.ForceUsePublicEndpoint).(bool); ok { + usePublicEndpoint = forceUsePublicEndpoint + } + if err := handler.InitOSSClient(usePublicEndpoint); err != nil { return "", err } diff --git a/pkg/filesystem/driver/oss/handler_test.go b/pkg/filesystem/driver/oss/handler_test.go index e571d55..267f8fc 100644 --- a/pkg/filesystem/driver/oss/handler_test.go +++ b/pkg/filesystem/driver/oss/handler_test.go @@ -30,13 +30,19 @@ func TestDriver_InitOSSClient(t *testing.T) { // 成功 { - asserts.NoError(handler.InitOSSClient()) + asserts.NoError(handler.InitOSSClient(false)) + } + + // 使用内网Endpoint + { + handler.Policy.OptionsSerialized.ServerSideEndpoint = "endpoint2" + asserts.NoError(handler.InitOSSClient(false)) } // 未指定存储策略 { handler := Driver{} - asserts.Error(handler.InitOSSClient()) + asserts.Error(handler.InitOSSClient(false)) } } @@ -182,6 +188,19 @@ func TestDriver_Source(t *testing.T) { asserts.Empty(query.Get("Signature")) asserts.Contains(resURL.String(), handler.Policy.BaseURL) } + + // 强制使用公网 Endpoint + { + handler.Policy.BaseURL = "" + handler.Policy.OptionsSerialized.ServerSideEndpoint = "endpoint.com" + res, err := handler.Source(context.WithValue(context.Background(), fsctx.ForceUsePublicEndpoint, false), "/123", url.URL{}, 10, false, 0) + asserts.NoError(err) + resURL, err := url.Parse(res) + asserts.NoError(err) + query := resURL.Query() + asserts.Empty(query.Get("Signature")) + asserts.Contains(resURL.String(), "endpoint.com") + } } func TestDriver_Thumb(t *testing.T) { diff --git a/pkg/filesystem/fsctx/context.go b/pkg/filesystem/fsctx/context.go index d8b9061..6b3f81d 100644 --- a/pkg/filesystem/fsctx/context.go +++ b/pkg/filesystem/fsctx/context.go @@ -33,4 +33,6 @@ const ( IgnoreConflictCtx // RetryCtx 失败重试次数 RetryCtx + // ForceUsePublicEndpoint 强制使用公网 Endpoint + ForceUsePublicEndpoint ) From 7279be29246a184e325607ad271c7ac220b85fdd Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 1 Dec 2020 19:22:52 +0800 Subject: [PATCH 17/34] Fix: user storage might be returned twice when OneDrive uploading canceled in WebDAV requests --- pkg/filesystem/driver/oss/handler.go | 4 +- pkg/filesystem/driver/oss/handler_test.go | 2 +- pkg/filesystem/fsctx/context.go | 8 +++- pkg/filesystem/hooks.go | 21 ++++++++- pkg/filesystem/hooks_test.go | 54 +++++++++++++++++++++++ pkg/webdav/webdav.go | 5 +++ 6 files changed, 88 insertions(+), 6 deletions(-) diff --git a/pkg/filesystem/driver/oss/handler.go b/pkg/filesystem/driver/oss/handler.go index 9dd5353..fc4f9a3 100644 --- a/pkg/filesystem/driver/oss/handler.go +++ b/pkg/filesystem/driver/oss/handler.go @@ -186,7 +186,7 @@ func (handler Driver) Get(ctx context.Context, path string) (response.RSCloser, ctx = context.WithValue(ctx, VersionID, time.Now().UnixNano()) // 尽可能使用私有 Endpoint - ctx = context.WithValue(ctx, fsctx.ForceUsePublicEndpoint, false) + ctx = context.WithValue(ctx, fsctx.ForceUsePublicEndpointCtx, false) // 获取文件源地址 downloadURL, err := handler.Source( @@ -317,7 +317,7 @@ func (handler Driver) Source( ) (string, error) { // 初始化客户端 usePublicEndpoint := true - if forceUsePublicEndpoint, ok := ctx.Value(fsctx.ForceUsePublicEndpoint).(bool); ok { + if forceUsePublicEndpoint, ok := ctx.Value(fsctx.ForceUsePublicEndpointCtx).(bool); ok { usePublicEndpoint = forceUsePublicEndpoint } if err := handler.InitOSSClient(usePublicEndpoint); err != nil { diff --git a/pkg/filesystem/driver/oss/handler_test.go b/pkg/filesystem/driver/oss/handler_test.go index 267f8fc..3758bba 100644 --- a/pkg/filesystem/driver/oss/handler_test.go +++ b/pkg/filesystem/driver/oss/handler_test.go @@ -193,7 +193,7 @@ func TestDriver_Source(t *testing.T) { { handler.Policy.BaseURL = "" handler.Policy.OptionsSerialized.ServerSideEndpoint = "endpoint.com" - res, err := handler.Source(context.WithValue(context.Background(), fsctx.ForceUsePublicEndpoint, false), "/123", url.URL{}, 10, false, 0) + res, err := handler.Source(context.WithValue(context.Background(), fsctx.ForceUsePublicEndpointCtx, false), "/123", url.URL{}, 10, false, 0) asserts.NoError(err) resURL, err := url.Parse(res) asserts.NoError(err) diff --git a/pkg/filesystem/fsctx/context.go b/pkg/filesystem/fsctx/context.go index 6b3f81d..0056043 100644 --- a/pkg/filesystem/fsctx/context.go +++ b/pkg/filesystem/fsctx/context.go @@ -33,6 +33,10 @@ const ( IgnoreConflictCtx // RetryCtx 失败重试次数 RetryCtx - // ForceUsePublicEndpoint 强制使用公网 Endpoint - ForceUsePublicEndpoint + // ForceUsePublicEndpointCtx 强制使用公网 Endpoint + ForceUsePublicEndpointCtx + // CancelFuncCtx Context 取消函數 + CancelFuncCtx + // ValidateCapacityOnceCtx 限定归还容量的操作只執行一次 + ValidateCapacityOnceCtx ) diff --git a/pkg/filesystem/hooks.go b/pkg/filesystem/hooks.go index eb8bbed..3b5755d 100644 --- a/pkg/filesystem/hooks.go +++ b/pkg/filesystem/hooks.go @@ -5,6 +5,7 @@ import ( "errors" "io/ioutil" "strings" + "sync" model "github.com/cloudreve/Cloudreve/v3/models" "github.com/cloudreve/Cloudreve/v3/pkg/conf" @@ -186,12 +187,30 @@ func HookClearFileSize(ctx context.Context, fs *FileSystem) error { return originFile.UpdateSize(0) } +// HookCancelContext 取消上下文 +func HookCancelContext(ctx context.Context, fs *FileSystem) error { + cancelFunc, ok := ctx.Value(fsctx.CancelFuncCtx).(context.CancelFunc) + if ok { + cancelFunc() + } + return nil +} + // HookGiveBackCapacity 归还用户容量 func HookGiveBackCapacity(ctx context.Context, fs *FileSystem) error { file := ctx.Value(fsctx.FileHeaderCtx).(FileHeader) + once, ok := ctx.Value(fsctx.ValidateCapacityOnceCtx).(*sync.Once) + if !ok { + once = &sync.Once{} + } // 归还用户容量 - if !fs.User.DeductionStorage(file.GetSize()) { + res := true + once.Do(func() { + res = fs.User.DeductionStorage(file.GetSize()) + }) + + if !res { return errors.New("无法继续降低用户已用存储") } return nil diff --git a/pkg/filesystem/hooks_test.go b/pkg/filesystem/hooks_test.go index 59fe56b..2548430 100644 --- a/pkg/filesystem/hooks_test.go +++ b/pkg/filesystem/hooks_test.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "strings" + "sync" "testing" "github.com/DATA-DOG/go-sqlmock" @@ -654,3 +655,56 @@ func TestFileSystem_CleanHooks(t *testing.T) { asserts.Len(fs.Hooks, 0) } } + +func TestHookCancelContext(t *testing.T) { + asserts := assert.New(t) + fs := &FileSystem{} + ctx, cancel := context.WithCancel(context.Background()) + + // empty ctx + { + asserts.NoError(HookCancelContext(ctx, fs)) + select { + case <-ctx.Done(): + t.Errorf("Channel should not be closed") + default: + + } + } + + // with cancel ctx + { + ctx = context.WithValue(ctx, fsctx.CancelFuncCtx, cancel) + asserts.NoError(HookCancelContext(ctx, fs)) + _, ok := <-ctx.Done() + asserts.False(ok) + } +} + +func TestHookGiveBackCapacity(t *testing.T) { + asserts := assert.New(t) + fs := &FileSystem{ + User: &model.User{ + Model: gorm.Model{ID: 1}, + Storage: 10, + }, + } + ctx := context.WithValue(context.Background(), fsctx.FileHeaderCtx, local.FileStream{Size: 1}) + + // without once limit + { + asserts.NoError(HookGiveBackCapacity(ctx, fs)) + asserts.EqualValues(9, fs.User.Storage) + asserts.NoError(HookGiveBackCapacity(ctx, fs)) + asserts.EqualValues(8, fs.User.Storage) + } + + // with once limit + { + ctx = context.WithValue(ctx, fsctx.ValidateCapacityOnceCtx, &sync.Once{}) + asserts.NoError(HookGiveBackCapacity(ctx, fs)) + asserts.EqualValues(7, fs.User.Storage) + asserts.NoError(HookGiveBackCapacity(ctx, fs)) + asserts.EqualValues(7, fs.User.Storage) + } +} diff --git a/pkg/webdav/webdav.go b/pkg/webdav/webdav.go index a4f9f20..dbfbdd3 100644 --- a/pkg/webdav/webdav.go +++ b/pkg/webdav/webdav.go @@ -14,6 +14,7 @@ import ( "path" "strconv" "strings" + "sync" "time" model "github.com/cloudreve/Cloudreve/v3/models" @@ -315,6 +316,8 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst ctx, cancel := context.WithCancel(context.Background()) defer cancel() ctx = context.WithValue(ctx, fsctx.HTTPCtx, r.Context()) + ctx = context.WithValue(ctx, fsctx.CancelFuncCtx, cancel) + ctx = context.WithValue(ctx, fsctx.ValidateCapacityOnceCtx, &sync.Once{}) fileSize, err := strconv.ParseUint(r.Header.Get("Content-Length"), 10, 64) if err != nil { @@ -351,6 +354,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst fs.Use("AfterUploadCanceled", filesystem.HookCleanFileContent) fs.Use("AfterUploadCanceled", filesystem.HookClearFileSize) fs.Use("AfterUploadCanceled", filesystem.HookGiveBackCapacity) + fs.Use("AfterUploadCanceled", filesystem.HookCancelContext) fs.Use("AfterUpload", filesystem.GenericAfterUpdate) fs.Use("AfterValidateFailed", filesystem.HookCleanFileContent) fs.Use("AfterValidateFailed", filesystem.HookClearFileSize) @@ -362,6 +366,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request, fs *filesyst fs.Use("BeforeUpload", filesystem.HookValidateCapacity) fs.Use("AfterUploadCanceled", filesystem.HookDeleteTempFile) fs.Use("AfterUploadCanceled", filesystem.HookGiveBackCapacity) + fs.Use("AfterUploadCanceled", filesystem.HookCancelContext) fs.Use("AfterUpload", filesystem.GenericAfterUpload) fs.Use("AfterValidateFailed", filesystem.HookDeleteTempFile) fs.Use("AfterValidateFailed", filesystem.HookGiveBackCapacity) From 6486e8799b0b36cd23c859fcd4b0fbbf368884bb Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 3 Dec 2020 18:10:10 +0800 Subject: [PATCH 18/34] Fix: user storage might be returned twice when canceling uploading request (#645) --- routers/controllers/file.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routers/controllers/file.go b/routers/controllers/file.go index 5fb7edb..c914ed5 100644 --- a/routers/controllers/file.go +++ b/routers/controllers/file.go @@ -7,6 +7,7 @@ import ( "net/http" "net/url" "strconv" + "sync" model "github.com/cloudreve/Cloudreve/v3/models" "github.com/cloudreve/Cloudreve/v3/pkg/filesystem" @@ -317,6 +318,7 @@ func FileUploadStream(c *gin.Context) { fs.Use("AfterUploadFailed", filesystem.HookGiveBackCapacity) // 执行上传 + ctx = context.WithValue(ctx, fsctx.ValidateCapacityOnceCtx, &sync.Once{}) uploadCtx := context.WithValue(ctx, fsctx.GinCtx, c) err = fs.Upload(uploadCtx, fileData) if err != nil { From f7c80391169001e75737f773ea82d3eab344d341 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 6 Dec 2020 16:49:49 +0800 Subject: [PATCH 19/34] Feat: execute database script to calibrate user storage --- assets | 2 +- bootstrap/script.go | 18 ++++++++++++++++++ main.go | 12 ++++++++++-- models/scripts/invoker.go | 25 +++++++++++++++++++++++++ models/scripts/storage.go | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 bootstrap/script.go create mode 100644 models/scripts/invoker.go create mode 100644 models/scripts/storage.go diff --git a/assets b/assets index 1bd0933..b473ad0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1bd093315526ac8585a8c7a3499e50f2a13d82fa +Subproject commit b473ad0e45d4dcf4b090fbc155871009c084a92a diff --git a/bootstrap/script.go b/bootstrap/script.go new file mode 100644 index 0000000..9168dfa --- /dev/null +++ b/bootstrap/script.go @@ -0,0 +1,18 @@ +package bootstrap + +import ( + "context" + "github.com/cloudreve/Cloudreve/v3/models/scripts" + "github.com/cloudreve/Cloudreve/v3/pkg/util" +) + +func RunScript(name string) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + if err := scripts.RunDBScript(name, ctx); err != nil { + util.Log().Error("数据库脚本执行失败: %s", err) + return + } + + util.Log().Info("数据库脚本 [%s] 执行完毕", name) +} diff --git a/main.go b/main.go index d1b4e53..2183de7 100644 --- a/main.go +++ b/main.go @@ -10,13 +10,15 @@ import ( ) var ( - isEject bool - confPath string + isEject bool + confPath string + scriptName string ) func init() { flag.StringVar(&confPath, "c", util.RelativePath("conf.ini"), "配置文件路径") flag.BoolVar(&isEject, "eject", false, "导出内置静态资源") + flag.StringVar(&scriptName, "database-script", "", "运行内置数据库助手脚本") flag.Parse() bootstrap.Init(confPath) } @@ -28,6 +30,12 @@ func main() { return } + if scriptName != "" { + // 开始运行助手数据库脚本 + bootstrap.RunScript(scriptName) + return + } + api := routers.InitRouter() // 如果启用了SSL diff --git a/models/scripts/invoker.go b/models/scripts/invoker.go new file mode 100644 index 0000000..af0155b --- /dev/null +++ b/models/scripts/invoker.go @@ -0,0 +1,25 @@ +package scripts + +import ( + "context" + "fmt" +) + +type DBScript interface { + Run(ctx context.Context) +} + +var availableScripts = make(map[string]DBScript) + +func RunDBScript(name string, ctx context.Context) error { + if script, ok := availableScripts[name]; ok { + script.Run(ctx) + return nil + } + + return fmt.Errorf("数据库脚本 [%s] 不存在", name) +} + +func register(name string, script DBScript) { + availableScripts[name] = script +} diff --git a/models/scripts/storage.go b/models/scripts/storage.go new file mode 100644 index 0000000..9e152d5 --- /dev/null +++ b/models/scripts/storage.go @@ -0,0 +1,37 @@ +package scripts + +import ( + "context" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" +) + +type UserStorageCalibration int + +func init() { + register("CalibrateUserStorage", UserStorageCalibration(0)) +} + +type storageResult struct { + Total uint64 +} + +// Run 运行脚本校准所有用户容量 +func (script UserStorageCalibration) Run(ctx context.Context) { + // 列出所有用户 + var res []model.User + model.DB.Model(&model.User{}).Find(&res) + + // 逐个检查容量 + for _, user := range res { + // 计算正确的容量 + var total storageResult + model.DB.Model(&model.File{}).Where("user_id = ?", user.ID).Select("sum(size) as total").Scan(&total) + // 更新用户的容量 + if user.Storage != total.Total { + util.Log().Info("将用户 [%s] 的容量由 %d 校准为 %d", user.Email, + user.Storage, total.Total) + model.DB.Model(&user).Update("storage", total.Total) + } + } +} From 0cfa61e264f0773da48ef214600f43d31b52d304 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Sun, 6 Dec 2020 16:50:08 +0800 Subject: [PATCH 20/34] Test: user storage calibration script --- models/scripts/invoker_test.go | 49 ++++++++++++++++++++++++++++++++++ models/scripts/storage_test.go | 38 ++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 models/scripts/invoker_test.go create mode 100644 models/scripts/storage_test.go diff --git a/models/scripts/invoker_test.go b/models/scripts/invoker_test.go new file mode 100644 index 0000000..0ca324b --- /dev/null +++ b/models/scripts/invoker_test.go @@ -0,0 +1,49 @@ +package scripts + +import ( + "context" + "database/sql" + "github.com/DATA-DOG/go-sqlmock" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/jinzhu/gorm" + "github.com/stretchr/testify/assert" + "testing" +) + +var mock sqlmock.Sqlmock +var mockDB *gorm.DB + +type TestScript int + +func (script TestScript) Run(ctx context.Context) { + +} + +// TestMain 初始化数据库Mock +func TestMain(m *testing.M) { + var db *sql.DB + var err error + db, mock, err = sqlmock.New() + if err != nil { + panic("An error was not expected when opening a stub database connection") + } + model.DB, _ = gorm.Open("mysql", db) + mockDB = model.DB + defer db.Close() + m.Run() +} + +func TestRunDBScript(t *testing.T) { + asserts := assert.New(t) + register("test", TestScript(0)) + + // 不存在 + { + asserts.Error(RunDBScript("else", context.Background())) + } + + // 存在 + { + asserts.NoError(RunDBScript("test", context.Background())) + } +} diff --git a/models/scripts/storage_test.go b/models/scripts/storage_test.go new file mode 100644 index 0000000..7287724 --- /dev/null +++ b/models/scripts/storage_test.go @@ -0,0 +1,38 @@ +package scripts + +import ( + "context" + "github.com/DATA-DOG/go-sqlmock" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestUserStorageCalibration_Run(t *testing.T) { + asserts := assert.New(t) + script := UserStorageCalibration(0) + + // 容量异常 + { + mock.ExpectQuery("SELECT(.+)users(.+)"). + WillReturnRows(sqlmock.NewRows([]string{"id", "email", "storage"}).AddRow(1, "a@a.com", 10)) + mock.ExpectQuery("SELECT(.+)files(.+)"). + WithArgs(1). + WillReturnRows(sqlmock.NewRows([]string{"total"}).AddRow(11)) + mock.ExpectBegin() + mock.ExpectExec("UPDATE(.+)").WillReturnResult(sqlmock.NewResult(1, 1)) + mock.ExpectCommit() + script.Run(context.Background()) + asserts.NoError(mock.ExpectationsWereMet()) + } + + // 容量正常 + { + mock.ExpectQuery("SELECT(.+)users(.+)"). + WillReturnRows(sqlmock.NewRows([]string{"id", "email", "storage"}).AddRow(1, "a@a.com", 10)) + mock.ExpectQuery("SELECT(.+)files(.+)"). + WithArgs(1). + WillReturnRows(sqlmock.NewRows([]string{"total"}).AddRow(10)) + script.Run(context.Background()) + asserts.NoError(mock.ExpectationsWereMet()) + } +} From bd2bdf253bfa93db6d7d1023df9bcd16faf4cd90 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 17:30:22 +0800 Subject: [PATCH 21/34] Feat: using custom reverse proxying in OneDrive file downloading --- models/policy.go | 4 +++- pkg/filesystem/driver/onedrive/handler.go | 25 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/models/policy.go b/models/policy.go index 34d6a2b..52f9668 100644 --- a/models/policy.go +++ b/models/policy.go @@ -47,8 +47,10 @@ type PolicyOption struct { FileType []string `json:"file_type"` // MimeType MimeType string `json:"mimetype"` - // OdRedirect Onedrive重定向地址 + // OdRedirect Onedrive 重定向地址 OdRedirect string `json:"od_redirect,omitempty"` + // OdProxy Onedrive 反代地址 + OdProxy string `json:"od_proxy,omitempty"` // Region 区域代码 Region string `json:"region,omitempty"` // ServerSideEndpoint 服务端请求使用的 Endpoint,为空时使用 Policy.Server 字段 diff --git a/pkg/filesystem/driver/onedrive/handler.go b/pkg/filesystem/driver/onedrive/handler.go index 8afe66a..2bedb16 100644 --- a/pkg/filesystem/driver/onedrive/handler.go +++ b/pkg/filesystem/driver/onedrive/handler.go @@ -154,7 +154,7 @@ func (handler Driver) Source( ) (string, error) { // 尝试从缓存中查找 if cachedURL, ok := cache.Get(fmt.Sprintf("onedrive_source_%d_%s", handler.Policy.ID, path)); ok { - return cachedURL.(string), nil + return handler.replaceSourceHost(cachedURL.(string)) } // 缓存不存在,重新获取 @@ -166,11 +166,32 @@ func (handler Driver) Source( res.DownloadURL, model.GetIntSetting("onedrive_source_timeout", 1800), ) - return res.DownloadURL, nil + return handler.replaceSourceHost(res.DownloadURL) } return "", err } +func (handler Driver) replaceSourceHost(origin string) (string, error) { + if handler.Policy.OptionsSerialized.OdProxy != "" { + source, err := url.Parse(origin) + if err != nil { + return "", err + } + + cdn, err := url.Parse(handler.Policy.OptionsSerialized.OdProxy) + if err != nil { + return "", err + } + + // 替换反代地址 + source.Scheme = cdn.Scheme + source.Host = cdn.Host + return source.String(), nil + } + + return origin, nil +} + // Token 获取上传会话URL func (handler Driver) Token(ctx context.Context, TTL int64, key string) (serializer.UploadCredential, error) { From 5b44606276fd2f0f03aca837889cf086967c6ae2 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 17:31:37 +0800 Subject: [PATCH 22/34] Test: replace cdn proxy url for OneDrive policy --- .../driver/onedrive/handller_test.go | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pkg/filesystem/driver/onedrive/handller_test.go diff --git a/pkg/filesystem/driver/onedrive/handller_test.go b/pkg/filesystem/driver/onedrive/handller_test.go new file mode 100644 index 0000000..147a547 --- /dev/null +++ b/pkg/filesystem/driver/onedrive/handller_test.go @@ -0,0 +1,38 @@ +package onedrive + +import ( + model "github.com/cloudreve/Cloudreve/v3/models" + "testing" +) + +func TestDriver_replaceSourceHost(t *testing.T) { + tests := []struct { + name string + origin string + cdn string + want string + wantErr bool + }{ + {"TestNoReplace", "http://1dr.ms/download.aspx?123456", "", "http://1dr.ms/download.aspx?123456", false}, + {"TestReplaceCorrect", "http://1dr.ms/download.aspx?123456", "https://test.com:8080", "https://test.com:8080/download.aspx?123456", false}, + {"TestCdnFormatError", "http://1dr.ms/download.aspx?123456", string([]byte{0x7f}), "", true}, + {"TestSrcFormatError", string([]byte{0x7f}), "https://test.com:8080", "", true}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + policy := &model.Policy{} + policy.OptionsSerialized.OdProxy = tt.cdn + handler := Driver{ + Policy: policy, + } + got, err := handler.replaceSourceHost(tt.origin) + if (err != nil) != tt.wantErr { + t.Errorf("replaceSourceHost() error = %v, wantErr %v", err, tt.wantErr) + return + } + if got != tt.want { + t.Errorf("replaceSourceHost() got = %v, want %v", got, tt.want) + } + }) + } +} From 5d406f1c6a1464c5eac7c8f4b0d25557376a04c9 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 17:36:19 +0800 Subject: [PATCH 23/34] Feat: use history router mode --- middleware/frontend.go | 69 +++++++++++++++++++++++++++++++++ routers/controllers/callback.go | 2 +- routers/router.go | 5 +-- service/share/manage.go | 2 +- service/user/login.go | 3 +- service/user/register.go | 2 +- 6 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 middleware/frontend.go diff --git a/middleware/frontend.go b/middleware/frontend.go new file mode 100644 index 0000000..7fb7606 --- /dev/null +++ b/middleware/frontend.go @@ -0,0 +1,69 @@ +package middleware + +import ( + "github.com/cloudreve/Cloudreve/v3/bootstrap" + model "github.com/cloudreve/Cloudreve/v3/models" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "io/ioutil" + "net/http" + "strings" +) + +// FrontendFileHandler 前端静态文件处理 +func FrontendFileHandler() gin.HandlerFunc { + ignoreFunc := func(c *gin.Context) { + c.Next() + } + + if bootstrap.StaticFS == nil { + return ignoreFunc + } + + // 读取index.html + file, err := bootstrap.StaticFS.Open("/index.html") + if err != nil { + util.Log().Warning("静态文件[index.html]不存在,可能会影响首页展示") + return ignoreFunc + } + + fileContentBytes, err := ioutil.ReadAll(file) + if err != nil { + util.Log().Warning("静态文件[index.html]读取失败,可能会影响首页展示") + return ignoreFunc + } + fileContent := string(fileContentBytes) + + fileServer := http.FileServer(bootstrap.StaticFS) + return func(c *gin.Context) { + path := c.Request.URL.Path + + // API 跳过 + if strings.HasPrefix(path, "/api") || strings.HasPrefix(path, "/custom") || strings.HasPrefix(path, "/custom") || path == "manifest.json" { + c.Next() + return + } + + // 不存在的路径和index.html均返回index.html + if !bootstrap.StaticFS.Exists("/", path) || (path == "/index.html") || (path == "/") { + // 读取、替换站点设置 + options := model.GetSettingByNames("siteName", "siteKeywords", "siteScript", + "pwa_small_icon") + finalHTML := util.Replace(map[string]string{ + "{siteName}": options["siteName"], + "{siteDes}": options["siteDes"], + "{siteScript}": options["siteScript"], + "{pwa_small_icon}": options["pwa_small_icon"], + }, fileContent) + + c.Header("Content-Type", "text/html") + c.String(200, finalHTML) + c.Abort() + return + } + + // 存在的静态文件 + fileServer.ServeHTTP(c.Writer, c.Request) + c.Abort() + } +} diff --git a/routers/controllers/callback.go b/routers/controllers/callback.go index 56dd1e0..8c5a7f9 100644 --- a/routers/controllers/callback.go +++ b/routers/controllers/callback.go @@ -91,7 +91,7 @@ func OneDriveOAuth(c *gin.Context) { queries.Add("msg", res.Msg) queries.Add("err", res.Error) redirect.RawQuery = queries.Encode() - c.Redirect(301, "/#"+redirect.String()) + c.Redirect(301, "/"+redirect.String()) } else { c.JSON(200, ErrorResponse(err)) } diff --git a/routers/router.go b/routers/router.go index baf5253..71659ee 100644 --- a/routers/router.go +++ b/routers/router.go @@ -1,7 +1,6 @@ package routers import ( - "github.com/cloudreve/Cloudreve/v3/bootstrap" "github.com/cloudreve/Cloudreve/v3/middleware" "github.com/cloudreve/Cloudreve/v3/pkg/conf" "github.com/cloudreve/Cloudreve/v3/pkg/hashid" @@ -9,7 +8,6 @@ import ( "github.com/cloudreve/Cloudreve/v3/routers/controllers" "github.com/gin-contrib/cors" "github.com/gin-contrib/gzip" - "github.com/gin-contrib/static" "github.com/gin-gonic/gin" ) @@ -82,8 +80,7 @@ func InitMasterRouter() *gin.Engine { 静态资源 */ r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{"/api/"}))) - r.Use(middleware.InjectSiteInfo()) - r.Use(static.Serve("/", bootstrap.StaticFS)) + r.Use(middleware.FrontendFileHandler()) r.GET("manifest.json", controllers.Manifest) v3 := r.Group("/api/v3") diff --git a/service/share/manage.go b/service/share/manage.go index 6f4c739..bd826e1 100644 --- a/service/share/manage.go +++ b/service/share/manage.go @@ -139,7 +139,7 @@ func (service *ShareCreateService) Create(c *gin.Context) serializer.Response { uid := hashid.HashID(id, hashid.ShareID) // 最终得到分享链接 siteURL := model.GetSiteURL() - sharePath, _ := url.Parse("/#/s/" + uid) + sharePath, _ := url.Parse("/s/" + uid) shareURL := siteURL.ResolveReference(sharePath) return serializer.Response{ diff --git a/service/user/login.go b/service/user/login.go index 6c2262e..8854207 100644 --- a/service/user/login.go +++ b/service/user/login.go @@ -3,7 +3,6 @@ package user import ( "fmt" "net/url" - "strings" "time" model "github.com/cloudreve/Cloudreve/v3/models" @@ -108,7 +107,7 @@ func (service *UserResetEmailService) Reset(c *gin.Context) serializer.Response finalURL.RawQuery = queries.Encode() // 发送密码重设邮件 - title, body := email.NewResetEmail(user.Nick, strings.ReplaceAll(finalURL.String(), "/reset", "/#/reset")) + title, body := email.NewResetEmail(user.Nick, finalURL.String()) if err := email.Send(user.Email, title, body); err != nil { return serializer.Err(serializer.CodeInternalSetting, "无法发送密码重设邮件", err) } diff --git a/service/user/register.go b/service/user/register.go index c968ba6..04083ad 100644 --- a/service/user/register.go +++ b/service/user/register.go @@ -95,7 +95,7 @@ func (service *UserRegisterService) Register(c *gin.Context) serializer.Response // 返送激活邮件 title, body := email.NewActivationEmail(user.Email, - strings.ReplaceAll(finalURL.String(), "/activate", "/#/activate"), + finalURL.String(), ) if err := email.Send(user.Email, title, body); err != nil { return serializer.Err(serializer.CodeInternalSetting, "无法发送激活邮件", err) From 5ab93a6e0d77a337dadbab0d192122f88c697fe6 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 18:15:02 +0800 Subject: [PATCH 24/34] Test: frontend middleware --- middleware/frontend.go | 4 +- middleware/frontend_test.go | 144 ++++++++++++++++++++++++++++++++++++ middleware/option.go | 48 ------------ middleware/option_test.go | 109 --------------------------- 4 files changed, 146 insertions(+), 159 deletions(-) create mode 100644 middleware/frontend_test.go diff --git a/middleware/frontend.go b/middleware/frontend.go index 7fb7606..551a209 100644 --- a/middleware/frontend.go +++ b/middleware/frontend.go @@ -39,13 +39,13 @@ func FrontendFileHandler() gin.HandlerFunc { path := c.Request.URL.Path // API 跳过 - if strings.HasPrefix(path, "/api") || strings.HasPrefix(path, "/custom") || strings.HasPrefix(path, "/custom") || path == "manifest.json" { + if strings.HasPrefix(path, "/api") || strings.HasPrefix(path, "/custom") || strings.HasPrefix(path, "/dav") || path == "/manifest.json" { c.Next() return } // 不存在的路径和index.html均返回index.html - if !bootstrap.StaticFS.Exists("/", path) || (path == "/index.html") || (path == "/") { + if (path == "/index.html") || (path == "/") || !bootstrap.StaticFS.Exists("/", path) { // 读取、替换站点设置 options := model.GetSettingByNames("siteName", "siteKeywords", "siteScript", "pwa_small_icon") diff --git a/middleware/frontend_test.go b/middleware/frontend_test.go new file mode 100644 index 0000000..d32529d --- /dev/null +++ b/middleware/frontend_test.go @@ -0,0 +1,144 @@ +package middleware + +import ( + "errors" + "github.com/cloudreve/Cloudreve/v3/bootstrap" + "github.com/cloudreve/Cloudreve/v3/pkg/cache" + "github.com/cloudreve/Cloudreve/v3/pkg/util" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" + testMock "github.com/stretchr/testify/mock" + "net/http" + "net/http/httptest" + "os" + "testing" +) + +type StaticMock struct { + testMock.Mock +} + +func (m StaticMock) Open(name string) (http.File, error) { + args := m.Called(name) + return args.Get(0).(http.File), args.Error(1) +} + +func (m StaticMock) Exists(prefix string, filepath string) bool { + args := m.Called(prefix, filepath) + return args.Bool(0) +} + +func TestFrontendFileHandler(t *testing.T) { + asserts := assert.New(t) + rec := httptest.NewRecorder() + + // 静态资源未加载 + { + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", "/", nil) + TestFunc(c) + asserts.False(c.IsAborted()) + } + + // index.html 不存在 + { + testStatic := &StaticMock{} + bootstrap.StaticFS = testStatic + testStatic.On("Open", "/index.html"). + Return(&os.File{}, errors.New("error")) + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", "/", nil) + TestFunc(c) + asserts.False(c.IsAborted()) + } + + // index.html 读取失败 + { + file, _ := util.CreatNestedFile("tests/index.html") + file.Close() + testStatic := &StaticMock{} + bootstrap.StaticFS = testStatic + testStatic.On("Open", "/index.html"). + Return(file, nil) + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", "/", nil) + TestFunc(c) + asserts.False(c.IsAborted()) + } + + // 成功且命中 + { + file, _ := util.CreatNestedFile("tests/index.html") + defer file.Close() + testStatic := &StaticMock{} + bootstrap.StaticFS = testStatic + testStatic.On("Open", "/index.html"). + Return(file, nil) + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", "/", nil) + + cache.Set("setting_siteName", "cloudreve", 0) + cache.Set("setting_siteKeywords", "cloudreve", 0) + cache.Set("setting_siteScript", "cloudreve", 0) + cache.Set("setting_pwa_small_icon", "cloudreve", 0) + + TestFunc(c) + asserts.True(c.IsAborted()) + } + + // 成功且命中静态文件 + { + file, _ := util.CreatNestedFile("tests/index.html") + defer file.Close() + testStatic := &StaticMock{} + bootstrap.StaticFS = testStatic + testStatic.On("Open", "/index.html"). + Return(file, nil) + testStatic.On("Exists", "/", "/2"). + Return(true) + testStatic.On("Open", "/2"). + Return(file, nil) + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", "/2", nil) + + TestFunc(c) + asserts.True(c.IsAborted()) + testStatic.AssertExpectations(t) + } + + // API 相关跳过 + { + for _, reqPath := range []string{"/api/user", "/manifest.json", "/dav/path"} { + file, _ := util.CreatNestedFile("tests/index.html") + defer file.Close() + testStatic := &StaticMock{} + bootstrap.StaticFS = testStatic + testStatic.On("Open", "/index.html"). + Return(file, nil) + TestFunc := FrontendFileHandler() + + c, _ := gin.CreateTestContext(rec) + c.Params = []gin.Param{} + c.Request, _ = http.NewRequest("GET", reqPath, nil) + + TestFunc(c) + asserts.False(c.IsAborted()) + } + } + +} diff --git a/middleware/option.go b/middleware/option.go index 6704bcf..daa3753 100644 --- a/middleware/option.go +++ b/middleware/option.go @@ -1,13 +1,9 @@ package middleware import ( - "io/ioutil" - - "github.com/cloudreve/Cloudreve/v3/bootstrap" model "github.com/cloudreve/Cloudreve/v3/models" "github.com/cloudreve/Cloudreve/v3/pkg/hashid" "github.com/cloudreve/Cloudreve/v3/pkg/serializer" - "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" ) @@ -42,47 +38,3 @@ func IsFunctionEnabled(key string) gin.HandlerFunc { c.Next() } } - -// InjectSiteInfo 向首页html中插入站点信息 -func InjectSiteInfo() gin.HandlerFunc { - ignoreFunc := func(c *gin.Context) { - c.Next() - } - if bootstrap.StaticFS == nil { - return ignoreFunc - } - - // 读取index.html - file, err := bootstrap.StaticFS.Open("/index.html") - if err != nil { - util.Log().Warning("静态文件[index.html]不存在,可能会影响首页展示") - return ignoreFunc - } - - fileContentBytes, err := ioutil.ReadAll(file) - if err != nil { - util.Log().Warning("静态文件[index.html]读取失败,可能会影响首页展示") - return ignoreFunc - } - fileContent := string(fileContentBytes) - - return func(c *gin.Context) { - if c.Request.URL.Path == "/" || c.Request.URL.Path == "/index.html" { - // 读取、替换站点设置 - options := model.GetSettingByNames("siteName", "siteKeywords", "siteScript", - "pwa_small_icon") - finalHTML := util.Replace(map[string]string{ - "{siteName}": options["siteName"], - "{siteDes}": options["siteDes"], - "{siteScript}": options["siteScript"], - "{pwa_small_icon}": options["pwa_small_icon"], - }, fileContent) - - c.Header("Content-Type", "text/html") - c.String(200, finalHTML) - c.Abort() - return - } - c.Next() - } -} diff --git a/middleware/option_test.go b/middleware/option_test.go index 512c2e8..5de824a 100644 --- a/middleware/option_test.go +++ b/middleware/option_test.go @@ -1,19 +1,14 @@ package middleware import ( - "errors" "net/http" "net/http/httptest" - "os" "testing" - "github.com/cloudreve/Cloudreve/v3/bootstrap" "github.com/cloudreve/Cloudreve/v3/pkg/cache" "github.com/cloudreve/Cloudreve/v3/pkg/hashid" - "github.com/cloudreve/Cloudreve/v3/pkg/util" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" - testMock "github.com/stretchr/testify/mock" ) func TestHashID(t *testing.T) { @@ -81,107 +76,3 @@ func TestIsFunctionEnabled(t *testing.T) { } } - -type StaticMock struct { - testMock.Mock -} - -func (m StaticMock) Open(name string) (http.File, error) { - args := m.Called(name) - return args.Get(0).(http.File), args.Error(1) -} - -func (m StaticMock) Exists(prefix string, filepath string) bool { - args := m.Called(prefix, filepath) - return args.Bool(0) -} - -func TestInjectSiteInfo(t *testing.T) { - asserts := assert.New(t) - rec := httptest.NewRecorder() - - // 静态资源未加载 - { - TestFunc := InjectSiteInfo() - - c, _ := gin.CreateTestContext(rec) - c.Params = []gin.Param{} - c.Request, _ = http.NewRequest("GET", "/", nil) - TestFunc(c) - asserts.False(c.IsAborted()) - } - - // index.html 不存在 - { - testStatic := &StaticMock{} - bootstrap.StaticFS = testStatic - testStatic.On("Open", "/index.html"). - Return(&os.File{}, errors.New("error")) - TestFunc := InjectSiteInfo() - - c, _ := gin.CreateTestContext(rec) - c.Params = []gin.Param{} - c.Request, _ = http.NewRequest("GET", "/", nil) - TestFunc(c) - asserts.False(c.IsAborted()) - } - - // index.html 读取失败 - { - file, _ := util.CreatNestedFile("tests/index.html") - file.Close() - testStatic := &StaticMock{} - bootstrap.StaticFS = testStatic - testStatic.On("Open", "/index.html"). - Return(file, nil) - TestFunc := InjectSiteInfo() - - c, _ := gin.CreateTestContext(rec) - c.Params = []gin.Param{} - c.Request, _ = http.NewRequest("GET", "/", nil) - TestFunc(c) - asserts.False(c.IsAborted()) - } - - // 成功且命中 - { - file, _ := util.CreatNestedFile("tests/index.html") - defer file.Close() - testStatic := &StaticMock{} - bootstrap.StaticFS = testStatic - testStatic.On("Open", "/index.html"). - Return(file, nil) - TestFunc := InjectSiteInfo() - - c, _ := gin.CreateTestContext(rec) - c.Params = []gin.Param{} - c.Request, _ = http.NewRequest("GET", "/", nil) - - cache.Set("setting_siteName", "cloudreve", 0) - cache.Set("setting_siteKeywords", "cloudreve", 0) - cache.Set("setting_siteScript", "cloudreve", 0) - cache.Set("setting_pwa_small_icon", "cloudreve", 0) - - TestFunc(c) - asserts.True(c.IsAborted()) - } - - // 成功且未命中 - { - file, _ := util.CreatNestedFile("tests/index.html") - defer file.Close() - testStatic := &StaticMock{} - bootstrap.StaticFS = testStatic - testStatic.On("Open", "/index.html"). - Return(file, nil) - TestFunc := InjectSiteInfo() - - c, _ := gin.CreateTestContext(rec) - c.Params = []gin.Param{} - c.Request, _ = http.NewRequest("GET", "/2", nil) - - TestFunc(c) - asserts.False(c.IsAborted()) - } - -} From 8057c4b8bc30e62520d23e34596644ea7ea99c9f Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 18:53:20 +0800 Subject: [PATCH 25/34] Update: submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index b473ad0..fb8ca79 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit b473ad0e45d4dcf4b090fbc155871009c084a92a +Subproject commit fb8ca793edf7c928773a29bdc5ec451d80a82e5e From c87109c8b12812941862380766aeef1678f9a2a6 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 19:55:23 +0800 Subject: [PATCH 26/34] Fix: incorrect attr column type in download table --- models/download.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/models/download.go b/models/download.go index 12b2e57..8b6599d 100644 --- a/models/download.go +++ b/models/download.go @@ -18,10 +18,10 @@ type Download struct { DownloadedSize uint64 // 文件大小 GID string `gorm:"size:32,index:gid"` // 任务ID Speed int // 下载速度 - Parent string `gorm:"type:text"` // 存储目录 - Attrs string `gorm:"type:text,size:65535"` // 任务状态属性 - Error string `gorm:"type:text"` // 错误描述 - Dst string `gorm:"type:text"` // 用户文件系统存储父目录路径 + Parent string `gorm:"type:text"` // 存储目录 + Attrs string `gorm:"size:65535"` // 任务状态属性 + Error string `gorm:"type:text"` // 错误描述 + Dst string `gorm:"type:text"` // 用户文件系统存储父目录路径 UserID uint // 发起者UID TaskID uint // 对应的转存任务ID From 055ed0e075d887db3e8824f8cf52c3297b7ed9f6 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Tue, 8 Dec 2020 20:13:42 +0800 Subject: [PATCH 27/34] Fix: standardize the use of error codes related to login credentials --- assets | 2 +- middleware/auth.go | 2 +- pkg/serializer/error.go | 2 ++ routers/controllers/user.go | 6 +++--- service/user/login.go | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/assets b/assets index fb8ca79..397bf45 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit fb8ca793edf7c928773a29bdc5ec451d80a82e5e +Subproject commit 397bf4569cee2152d6663fc5dd2bcff4ea84a954 diff --git a/middleware/auth.go b/middleware/auth.go index ca68f0e..fd0f143 100644 --- a/middleware/auth.go +++ b/middleware/auth.go @@ -35,7 +35,7 @@ func SignRequired() gin.HandlerFunc { } if err != nil { - c.JSON(200, serializer.Err(serializer.CodeCheckLogin, err.Error(), err)) + c.JSON(200, serializer.Err(serializer.CodeCredentialInvalid, err.Error(), err)) c.Abort() return } diff --git a/pkg/serializer/error.go b/pkg/serializer/error.go index 6a2bae8..0191cee 100644 --- a/pkg/serializer/error.go +++ b/pkg/serializer/error.go @@ -52,6 +52,8 @@ const ( CodeNotFound = 404 // CodeUploadFailed 上传出错 CodeUploadFailed = 40002 + // CodeCredentialInvalid 凭证无效 + CodeCredentialInvalid = 40001 // CodeCreateFolderFailed 目录创建失败 CodeCreateFolderFailed = 40003 // CodeObjectExist 对象已存在 diff --git a/routers/controllers/user.go b/routers/controllers/user.go index bbbf925..b710942 100644 --- a/routers/controllers/user.go +++ b/routers/controllers/user.go @@ -20,7 +20,7 @@ func StartLoginAuthn(c *gin.Context) { userName := c.Param("username") expectedUser, err := model.GetUserByEmail(userName) if err != nil { - c.JSON(200, serializer.Err(401, "用户不存在", err)) + c.JSON(200, serializer.Err(serializer.CodeNotFound, "用户不存在", err)) return } @@ -54,7 +54,7 @@ func FinishLoginAuthn(c *gin.Context) { userName := c.Param("username") expectedUser, err := model.GetUserByEmail(userName) if err != nil { - c.JSON(200, serializer.Err(401, "用户邮箱或密码错误", err)) + c.JSON(200, serializer.Err(serializer.CodeCredentialInvalid, "用户邮箱或密码错误", err)) return } @@ -72,7 +72,7 @@ func FinishLoginAuthn(c *gin.Context) { _, err = instance.FinishLogin(expectedUser, sessionData, c.Request) if err != nil { - c.JSON(200, serializer.Err(401, "登录验证失败", err)) + c.JSON(200, serializer.Err(serializer.CodeCredentialInvalid, "登录验证失败", err)) return } diff --git a/service/user/login.go b/service/user/login.go index 8854207..acea163 100644 --- a/service/user/login.go +++ b/service/user/login.go @@ -171,10 +171,10 @@ func (service *UserLoginService) Login(c *gin.Context) serializer.Response { // 一系列校验 if err != nil { - return serializer.Err(401, "用户邮箱或密码错误", err) + return serializer.Err(serializer.CodeCredentialInvalid, "用户邮箱或密码错误", err) } if authOK, _ := expectedUser.CheckPassword(service.Password); !authOK { - return serializer.Err(401, "用户邮箱或密码错误", nil) + return serializer.Err(serializer.CodeCredentialInvalid, "用户邮箱或密码错误", nil) } if expectedUser.Status == model.Baned || expectedUser.Status == model.OveruseBaned { return serializer.Err(403, "该账号已被封禁", nil) From 9f2f14cacf478ab5ccdd8384b616010dcffec242 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 10 Dec 2020 16:59:45 +0800 Subject: [PATCH 28/34] Fix: https://github.com/cloudreve/Cloudreve/issues/504 --- assets | 2 +- service/explorer/search.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets b/assets index 397bf45..3c03655 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 397bf4569cee2152d6663fc5dd2bcff4ea84a954 +Subproject commit 3c03655b4a7dfeb41f80ec285f626123dfef0c21 diff --git a/service/explorer/search.go b/service/explorer/search.go index 5e661f9..6a078f8 100644 --- a/service/explorer/search.go +++ b/service/explorer/search.go @@ -30,7 +30,7 @@ func (service *ItemSearchService) Search(c *gin.Context) serializer.Response { case "keywords": return service.SearchKeywords(c, fs, "%"+service.Keywords+"%") case "image": - return service.SearchKeywords(c, fs, "%.bmp", "%.flac", "%.iff", "%.png", "%.gif", "%.jpg", "%.jpge", "%.psd", "%.svg", "%.webp") + return service.SearchKeywords(c, fs, "%.bmp", "%.iff", "%.png", "%.gif", "%.jpg", "%.jpeg", "%.psd", "%.svg", "%.webp") case "video": return service.SearchKeywords(c, fs, "%.mp4", "%.flv", "%.avi", "%.wmv", "%.mkv", "%.rm", "%.rmvb", "%.mov", "%.ogv") case "audio": From feb1134a7c07652e5e6250e83f1ae23ff890bf6d Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 10 Dec 2020 17:05:06 +0800 Subject: [PATCH 29/34] Update submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 3c03655..157097c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 3c03655b4a7dfeb41f80ec285f626123dfef0c21 +Subproject commit 157097ced3d6c01eb6979ed98a94c55ef61f855b From 61e6d9b591a6416067d0ea935b9e9aba28e5c468 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Thu, 10 Dec 2020 17:26:39 +0800 Subject: [PATCH 30/34] Update version number --- assets | 2 +- pkg/conf/version.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets b/assets index 157097c..d882649 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 157097ced3d6c01eb6979ed98a94c55ef61f855b +Subproject commit d882649a86571b920067e9e500bb848332751104 diff --git a/pkg/conf/version.go b/pkg/conf/version.go index 8c7ea1b..58e4244 100644 --- a/pkg/conf/version.go +++ b/pkg/conf/version.go @@ -1,13 +1,13 @@ package conf // BackendVersion 当前后端版本号 -var BackendVersion = "3.1.1" +var BackendVersion = "3.2.0" // RequiredDBVersion 与当前版本匹配的数据库版本 -var RequiredDBVersion = "3.1.0" +var RequiredDBVersion = "3.2.0" // RequiredStaticVersion 与当前版本匹配的静态资源版本 -var RequiredStaticVersion = "3.1.1" +var RequiredStaticVersion = "3.2.0" // IsPro 是否为Pro版本 var IsPro = "false" From f35ad3fe0af150a0089a9658dab5949d12394618 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Wed, 6 Jan 2021 16:35:31 +0800 Subject: [PATCH 31/34] Fix: #663 --- routers/controllers/callback.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/routers/controllers/callback.go b/routers/controllers/callback.go index 8c5a7f9..9179ab5 100644 --- a/routers/controllers/callback.go +++ b/routers/controllers/callback.go @@ -1,7 +1,8 @@ package controllers import ( - "net/url" + model "github.com/cloudreve/Cloudreve/v3/models" + "path" "strconv" "github.com/cloudreve/Cloudreve/v3/pkg/serializer" @@ -85,13 +86,14 @@ func OneDriveOAuth(c *gin.Context) { var callbackBody callback.OneDriveOauthService if err := c.ShouldBindQuery(&callbackBody); err == nil { res := callbackBody.Auth(c) - redirect, _ := url.Parse("/admin/policy") + redirect := model.GetSiteURL() + redirect.Path = path.Join(redirect.Path, "/admin/policy") queries := redirect.Query() queries.Add("code", strconv.Itoa(res.Code)) queries.Add("msg", res.Msg) queries.Add("err", res.Error) redirect.RawQuery = queries.Encode() - c.Redirect(301, "/"+redirect.String()) + c.Redirect(303, redirect.String()) } else { c.JSON(200, ErrorResponse(err)) } From 488e62f76279ae5e329ef313d7e84dad08b4b23a Mon Sep 17 00:00:00 2001 From: Breeze Chen Date: Wed, 6 Jan 2021 17:01:24 +0800 Subject: [PATCH 32/34] Fix qiniu last modify time. (#691) --- pkg/filesystem/driver/qiniu/handler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/filesystem/driver/qiniu/handler.go b/pkg/filesystem/driver/qiniu/handler.go index 4b24cc5..d1b86b8 100644 --- a/pkg/filesystem/driver/qiniu/handler.go +++ b/pkg/filesystem/driver/qiniu/handler.go @@ -92,7 +92,7 @@ func (handler Driver) List(ctx context.Context, base string, recursive bool) ([] RelativePath: filepath.ToSlash(rel), Size: uint64(object.Fsize), IsDir: false, - LastModify: time.Now(), + LastModify: time.Unix(object.PutTime/10000000, 0), }) } From 08d998b41e6158158886be78854c3646908c787e Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Wed, 6 Jan 2021 17:38:20 +0800 Subject: [PATCH 33/34] Update submodule --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index d882649..0310282 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit d882649a86571b920067e9e500bb848332751104 +Subproject commit 0310282aeb1de0f65b0bea328aebf9e36966a66d From 3b22b4fd251800b99aee1396fcdd5655b5650a93 Mon Sep 17 00:00:00 2001 From: HFO4 <912394456@qq.com> Date: Wed, 6 Jan 2021 18:18:24 +0800 Subject: [PATCH 34/34] Update version number --- assets | 2 +- pkg/conf/version.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets b/assets index 0310282..92f6981 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 0310282aeb1de0f65b0bea328aebf9e36966a66d +Subproject commit 92f6981cb363046327deadd70d03015fd11deeb6 diff --git a/pkg/conf/version.go b/pkg/conf/version.go index 58e4244..890cbec 100644 --- a/pkg/conf/version.go +++ b/pkg/conf/version.go @@ -1,13 +1,13 @@ package conf // BackendVersion 当前后端版本号 -var BackendVersion = "3.2.0" +var BackendVersion = "3.2.1" // RequiredDBVersion 与当前版本匹配的数据库版本 var RequiredDBVersion = "3.2.0" // RequiredStaticVersion 与当前版本匹配的静态资源版本 -var RequiredStaticVersion = "3.2.0" +var RequiredStaticVersion = "3.2.1" // IsPro 是否为Pro版本 var IsPro = "false"