-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(website): Add Cache Clearing Functionality for Website Reverse P… #7551
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,7 @@ type IWebsiteService interface { | |
UpdateProxyFile(req request.NginxProxyUpdate) (err error) | ||
UpdateProxyCache(req request.NginxProxyCacheUpdate) (err error) | ||
GetProxyCache(id uint) (res response.NginxProxyCache, err error) | ||
ClearProxyCache(req request.NginxCommonReq) error | ||
|
||
GetAntiLeech(id uint) (*response.NginxAntiLeechRes, error) | ||
UpdateAntiLeech(req request.NginxAntiLeechUpdate) (err error) | ||
|
@@ -1822,6 +1823,28 @@ func (w WebsiteService) UpdateProxyFile(req request.NginxProxyUpdate) (err error | |
return updateNginxConfig(constant.NginxScopeServer, nil, &website) | ||
} | ||
|
||
func (w WebsiteService) ClearProxyCache(req request.NginxCommonReq) error { | ||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID)) | ||
if err != nil { | ||
return err | ||
} | ||
cacheDir := GetSitePath(website, SiteProxyDir) | ||
fileOp := files.NewFileOp() | ||
if fileOp.Stat(cacheDir) { | ||
if err = fileOp.CleanDir(cacheDir); err != nil { | ||
return err | ||
} | ||
} | ||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) | ||
if err != nil { | ||
return err | ||
} | ||
if err = opNginx(nginxInstall.ContainerName, constant.NginxReload); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
func (w WebsiteService) GetAuthBasics(req request.NginxAuthReq) (res response.NginxAuthRes, err error) { | ||
var ( | ||
website model.Website | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no specific knowledge cutoff you provided for checking the code. The current date given (September 1, 2021) might not be relevant to this question. Please mention the exact date if it's important. In terms of the code, there do seem to be some inconsistencies and minor errors that need resolution. For example:
To summarize, without proper context information on the knowledge cutoffs mentioned here, I can't make significant optimizations/suggest improvements right now. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,18 +51,6 @@ | |
> | ||
{{ $t('commons.button.set') }} | ||
</el-button> | ||
<el-divider v-if="data.app === 'OpenResty'" direction="vertical" /> | ||
<el-button | ||
v-if="data.app === 'OpenResty'" | ||
type="primary" | ||
@click="clear" | ||
link | ||
:disabled=" | ||
data.status === 'Installing' || (data.status !== 'Running' && data.app === 'OpenResty') | ||
" | ||
> | ||
{{ $t('nginx.clearProxyCache') }} | ||
</el-button> | ||
</div> | ||
<div class="ml-5" v-if="key === 'openresty' && (httpPort != 80 || httpsPort != 443)"> | ||
<el-tooltip | ||
|
@@ -91,7 +79,6 @@ import Status from '@/components/status/index.vue'; | |
import { ElMessageBox } from 'element-plus'; | ||
import i18n from '@/lang'; | ||
import { MsgSuccess } from '@/utils/message'; | ||
import { ClearNginxCache } from '@/api/modules/nginx'; | ||
|
||
const props = defineProps({ | ||
appKey: { | ||
|
@@ -146,16 +133,6 @@ const onCheck = async (key: any, name: any) => { | |
}); | ||
}; | ||
|
||
const clear = () => { | ||
ElMessageBox.confirm(i18n.global.t('nginx.clearProxyCacheWarn'), i18n.global.t('nginx.clearProxyCache'), { | ||
confirmButtonText: i18n.global.t('commons.button.confirm'), | ||
cancelButtonText: i18n.global.t('commons.button.cancel'), | ||
}).then(async () => { | ||
await ClearNginxCache(); | ||
MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); | ||
}); | ||
}; | ||
|
||
const onOperate = async (operation: string) => { | ||
em('update:maskShow', false); | ||
operateReq.operate = operation; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No discrepancies found during the analysis of the given code snippet. The changes look consistent with the context provided at the end of your message ("current date"). No need for further action based on these findings. The script includes checks if the environment is set to "OpenResty", displaying an indicator and performing different actions according to this setting:
Overall, no critical issues were observed in terms of programming style correctness or logic accuracy. Please feel free to ask if you need more assistance beyond what appears in plain text! Enjoy coding! |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference between the two code snippets is that one does not declare methods like "ClearProxyCache()" whereas the other calls this method in its implementation.
Potential improvement could be to ensure consistency with regards naming conventions or to add documentation and comments for the functions so developers are aware of their intended purpose. However, there might not be much deviation from standards since both pieces of code seem well-written with no major syntax issues found here. It would also help to clarify if these services need to be compatible across multiple versions and environments which may determine any necessary optimizations.