fix: 解决同名反向代理失败导致文件被删除的问题 (#910)

pull/919/head
zhengkunwang223 2023-05-06 19:13:34 +08:00 committed by GitHub
parent a0c329019f
commit 95ad101a08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -1195,12 +1195,14 @@ func (w WebsiteService) OperateProxy(req request.WebsiteProxyConfig) (err error)
}
fileName := fmt.Sprintf("%s.conf", req.Name)
includePath := path.Join(includeDir, fileName)
if !fileOp.Stat(includePath) {
_ = fileOp.CreateFile(includePath)
}
backName := fmt.Sprintf("%s.bak", req.Name)
backPath := path.Join(includeDir, backName)
if req.Operate == "create" && (fileOp.Stat(includePath) || fileOp.Stat(backPath)) {
err = buserr.New(constant.ErrNameIsExist)
return
}
defer func() {
if err != nil {
switch req.Operate {