add base path to importDB API call
This commit is contained in:
MHSanaei 2026-05-10 22:46:39 +02:00
parent b576fe9d61
commit 06f111f3c9
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
2 changed files with 9 additions and 7 deletions

View file

@ -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)

View file

@ -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)
}