mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 13:14:11 +00:00
fix
add base path to importDB API call
This commit is contained in:
parent
b576fe9d61
commit
06f111f3c9
2 changed files with 9 additions and 7 deletions
|
|
@ -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