Skip to content

Commit

Permalink
fix: 修复非加密下的文件夹重命名
Browse files Browse the repository at this point in the history
  • Loading branch information
realhuhu committed Aug 11, 2024
1 parent babe4f0 commit 9529ed6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion node-proxy/src/router/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const staticServer = serve(path.join(path.dirname(process.argv[1]), 'public'))
const staticRouter = new Router()

staticRouter.redirect('/index', '/public/index.html', 302)
staticRouter.all(/\/public\/*/, async (ctx, next) => {

staticRouter.all('/public/(.*)', async (ctx, next) => {
ctx.path = ctx.path.replace('/public', '')
await staticServer(ctx, next)
})
Expand Down
13 changes: 10 additions & 3 deletions node-proxy/src/router/webdav/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ const putHook = async (ctx: Context, state: ProxiedState<WebdavServer | AlistSer

const deleteHook = async (ctx: Context, state: ProxiedState<WebdavServer | AlistServer>, passwdInfo: PasswdInfo) => {
const urlPath = new URL(state.urlAddr).pathname
const realFileName = convertRealName(passwdInfo.password, passwdInfo.encType, urlPath)
const isDir = await getFileInfo(urlPath)

let urlAddr: string
if (isDir) {
urlAddr = state.urlAddr
} else {
const realFileName = convertRealName(passwdInfo.password, passwdInfo.encType, urlPath)
urlAddr = path.dirname(state.urlAddr) + '/' + realFileName
}

const urlAddr = path.dirname(state.urlAddr) + '/' + realFileName
logger.info(`webdav删除: ${urlAddr}`)

//删除缓存
Expand Down Expand Up @@ -230,7 +237,7 @@ export const webdavHookMiddleware: Middleware<ProxiedState<WebdavServer | AlistS
const encrypted = passwdInfo?.encName

// 需要把目的url的ip转化为真实ip
if ('MOVE,DELETE'.includes(method)) {
if ('MOVE,COPY'.includes(method)) {
ctx.req.headers.destination = flat(ctx.req.headers.destination).replace(state.selfHost, state.serverAddr)
}

Expand Down

0 comments on commit 9529ed6

Please sign in to comment.