mirror of
https://github.com/Alvin-Zilverstand/nginx-proxy-manager.git
synced 2026-11-24 23:23:15 +01:00
Prevent deleting certificate that is use
This commit is contained in:
1 parent
88b46ef9ef
commit
7ea64c46e9
2 files changed
+30
-4
No files matched your search
@@ -213,6 +213,21 @@ func GetUpstreamUseCount(upstreamID int) int {
|
||||
return totalRows
|
||||
}
|
||||
|
||||
// GetCertificateUseCount returns the number of hosts that are using
|
||||
// a certificate, and have not been deleted.
|
||||
func GetCertificateUseCount(certificateID int) int {
|
||||
db := database.GetInstance()
|
||||
query := fmt.Sprintf("SELECT COUNT(*) FROM %s WHERE certificate_id = ? AND is_deleted = ?", tableName)
|
||||
countRow := db.QueryRowx(query, certificateID, 0)
|
||||
var totalRows int
|
||||
queryErr := countRow.Scan(&totalRows)
|
||||
if queryErr != nil && queryErr != sql.ErrNoRows {
|
||||
logger.Debug("%s", query)
|
||||
return 0
|
||||
}
|
||||
return totalRows
|
||||
}
|
||||
|
||||
// AddPendingJobs is intended to be used at startup to add
|
||||
// anything pending to the JobQueue just once, based on
|
||||
// the database row status
|
||||
|
||||
Reference in new issue
Block a user