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:
GRCR13 2026-05-10 23:48:35 +03:00 committed by GitHub
parent 887fca86ec
commit 30469fcd10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 8 deletions

View file

@ -20,7 +20,7 @@ function exportDb() {
// The Go endpoint streams x-ui.db as a download. Setting // The Go endpoint streams x-ui.db as a download. Setting
// window.location triggers a browser download without leaving // window.location triggers a browser download without leaving
// the page (the Go side responds with Content-Disposition: attachment). // 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() { function importDb() {

View file

@ -343,10 +343,6 @@ func (a *ServerController) importDB(c *gin.Context) {
return return
} }
defer file.Close() defer file.Close()
// Always restart Xray before return
defer a.serverService.RestartXrayService()
// lastGetStatusTime removed; no longer needed
// Import it
err = a.serverService.ImportDB(file) err = a.serverService.ImportDB(file)
if err != nil { if err != nil {
jsonMsg(c, I18nWeb(c, "pages.index.importDatabaseError"), err) jsonMsg(c, I18nWeb(c, "pages.index.importDatabaseError"), err)

View file

@ -976,12 +976,18 @@ func (s *ServerService) ImportDB(file multipart.File) error {
return common.NewErrorf("Invalid or corrupt db file: %v", err) 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 { if errStop := s.StopXrayService(); errStop != nil {
logger.Warningf("Failed to stop Xray before DB import: %v", errStop) 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 { if errClose := database.CloseDB(); errClose != nil {
logger.Warningf("Failed to close existing DB before replacement: %v", errClose) 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() s.inboundService.MigrateDB()
// Start Xray xrayStopped = false
if err = s.RestartXrayService(); err != nil { if err = s.RestartXrayService(); err != nil {
return common.NewErrorf("Imported DB but failed to start Xray: %v", err) return common.NewErrorf("Imported DB but failed to start Xray: %v", err)
} }