mirror of
				https://github.com/1Panel-dev/1Panel.git
				synced 2025-10-31 19:26:02 +08:00 
			
		
		
		
	fix: 解决 mariadb 删除没有同步删除数据库表的问题 (#2280)
This commit is contained in:
		
							parent
							
								
									5a315a773a
								
							
						
					
					
						commit
						8bc6b409d9
					
				
					 1 changed files with 11 additions and 8 deletions
				
			
		|  | @ -252,14 +252,20 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b | ||||||
| 	if err := deleteLink(ctx, &install, deleteDB, forceDelete, deleteBackup); err != nil && !forceDelete { | 	if err := deleteLink(ctx, &install, deleteDB, forceDelete, deleteBackup); err != nil && !forceDelete { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	if install.App.Key == constant.AppOpenresty { | 
 | ||||||
|  | 	if DatabaseKeys[install.App.Key] > 0 { | ||||||
|  | 		_ = databaseRepo.Delete(ctx, databaseRepo.WithAppInstallID(install.ID)) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	switch install.App.Key { | ||||||
|  | 	case constant.AppOpenresty: | ||||||
| 		_ = websiteRepo.DeleteAll(ctx) | 		_ = websiteRepo.DeleteAll(ctx) | ||||||
| 		_ = websiteDomainRepo.DeleteAll(ctx) | 		_ = websiteDomainRepo.DeleteAll(ctx) | ||||||
| 	} | 	case constant.AppMysql, constant.AppMariaDB: | ||||||
| 	_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) |  | ||||||
| 	if install.App.Key == constant.AppMysql || install.App.Key == constant.AppMariaDB { |  | ||||||
| 		_ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) | 		_ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	_ = backupRepo.DeleteRecord(ctx, commonRepo.WithByType("app"), commonRepo.WithByName(install.App.Key), backupRepo.WithByDetailName(install.Name)) | ||||||
| 	uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/app/%s/%s", install.App.Key, install.Name)) | 	uploadDir := path.Join(global.CONF.System.BaseDir, fmt.Sprintf("1panel/uploads/app/%s/%s", install.App.Key, install.Name)) | ||||||
| 	if _, err := os.Stat(uploadDir); err == nil { | 	if _, err := os.Stat(uploadDir); err == nil { | ||||||
| 		_ = os.RemoveAll(uploadDir) | 		_ = os.RemoveAll(uploadDir) | ||||||
|  | @ -278,10 +284,7 @@ func deleteAppInstall(install model.AppInstall, deleteBackup bool, forceDelete b | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool, forceDelete bool, deleteBackup bool) error { | func deleteLink(ctx context.Context, install *model.AppInstall, deleteDB bool, forceDelete bool, deleteBackup bool) error { | ||||||
| 	if DatabaseKeys[install.App.Key] > 0 { | 
 | ||||||
| 		_ = databaseRepo.Delete(ctx, databaseRepo.WithAppInstallID(install.ID)) |  | ||||||
| 		_ = mysqlRepo.Delete(ctx, mysqlRepo.WithByMysqlName(install.Name)) |  | ||||||
| 	} |  | ||||||
| 	resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID)) | 	resources, _ := appInstallResourceRepo.GetBy(appInstallResourceRepo.WithAppInstallId(install.ID)) | ||||||
| 	if len(resources) == 0 { | 	if len(resources) == 0 { | ||||||
| 		return nil | 		return nil | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue