clear cache

This commit is contained in:
微凉
2021-11-01 22:42:24 +08:00
parent 6313939e8c
commit 5c2ce5b442
6 changed files with 49 additions and 11 deletions

15
server/cache.go Normal file
View File

@ -0,0 +1,15 @@
package server
import (
"github.com/Xhofe/alist/conf"
"github.com/gofiber/fiber/v2"
)
func ClearCache(ctx *fiber.Ctx) error {
err := conf.Cache.Clear(conf.Ctx)
if err != nil {
return ErrorResp(ctx,err,500)
}else {
return SuccessResp(ctx)
}
}

View File

@ -43,6 +43,9 @@ func Path(ctx *fiber.Ctx) error {
return ErrorResp(ctx, err, 500)
}
if file != nil {
if account.Type == "Native" {
file.Url = fmt.Sprintf("%s://%s/p%s",ctx.Protocol(),ctx.Hostname(),req.Path)
}
return ctx.JSON(Resp{
Code: 200,
Message: "file",
@ -75,7 +78,7 @@ func Link(ctx *fiber.Ctx) error {
}
if account.Type == "Native" {
return SuccessResp(ctx, fiber.Map{
"url":"",
"url":fmt.Sprintf("%s://%s/p%s",ctx.Protocol(),ctx.Hostname(),rawPath),
})
} else {
return SuccessResp(ctx,fiber.Map{

View File

@ -33,5 +33,6 @@ func InitApiRouter(app *fiber.App) {
admin.Get("/accounts", GetAccounts)
admin.Delete("/account", DeleteAccount)
admin.Get("/drivers", GetDrivers)
admin.Get("/clear_cache",ClearCache)
}
}