mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-05-13 09:36:05 +00:00
fix: backup path with webbasepath (#4223)
* Update BackupModal.vue add base path to importDB API call * fix add base path to importDB API call
This commit is contained in:
parent
887fca86ec
commit
30469fcd10
3 changed files with 10 additions and 8 deletions
|
|
@ -20,7 +20,7 @@ function exportDb() {
|
|||
// The Go endpoint streams x-ui.db as a download. Setting
|
||||
// window.location triggers a browser download without leaving
|
||||
// the page (the Go side responds with Content-Disposition: attachment).
|
||||
window.location = '/panel/api/server/getDb';
|
||||
window.location = window.__X_UI_BASE_PATH__+'panel/api/server/getDb';
|
||||
}
|
||||
|
||||
function importDb() {
|
||||
|
|
|
|||
|
|
@ -343,10 +343,6 @@ func (a *ServerController) importDB(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
defer file.Close()
|
||||
// Always restart Xray before return
|
||||
defer a.serverService.RestartXrayService()
|
||||
// lastGetStatusTime removed; no longer needed
|
||||
// Import it
|
||||
err = a.serverService.ImportDB(file)
|
||||
if err != nil {
|
||||
jsonMsg(c, I18nWeb(c, "pages.index.importDatabaseError"), err)
|
||||
|
|
|
|||
|
|
@ -976,12 +976,18 @@ func (s *ServerService) ImportDB(file multipart.File) error {
|
|||
return common.NewErrorf("Invalid or corrupt db file: %v", err)
|
||||
}
|
||||
|
||||
// Stop Xray (ignore error but log)
|
||||
xrayStopped := true
|
||||
defer func() {
|
||||
if xrayStopped {
|
||||
if errR := s.RestartXrayService(); errR != nil {
|
||||
logger.Warningf("Failed to restart Xray after DB import error: %v", errR)
|
||||
}
|
||||
}
|
||||
}()
|
||||
if errStop := s.StopXrayService(); errStop != nil {
|
||||
logger.Warningf("Failed to stop Xray before DB import: %v", errStop)
|
||||
}
|
||||
|
||||
// Close existing DB to release file locks (especially on Windows)
|
||||
if errClose := database.CloseDB(); errClose != nil {
|
||||
logger.Warningf("Failed to close existing DB before replacement: %v", errClose)
|
||||
}
|
||||
|
|
@ -1029,7 +1035,7 @@ func (s *ServerService) ImportDB(file multipart.File) error {
|
|||
|
||||
s.inboundService.MigrateDB()
|
||||
|
||||
// Start Xray
|
||||
xrayStopped = false
|
||||
if err = s.RestartXrayService(); err != nil {
|
||||
return common.NewErrorf("Imported DB but failed to start Xray: %v", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue