Skip to content

Commit

Permalink
fix: fix drop site error
Browse files Browse the repository at this point in the history
  • Loading branch information
tohidmalik002 committed Oct 31, 2024
1 parent 5e5c76c commit 5b931aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions frappe/commands/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@ def _drop_site(
from frappe.utils.backups import scheduled_backup

frappe.init(site=site)
frappe.flags.in_drop_site = True
frappe.connect()

try:
Expand Down
8 changes: 4 additions & 4 deletions frappe/database/postgres/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def last_query(self):
def close(self):
"""Close database connection."""
if self._conn:
if frappe.flags.in_install_db:
self._conn.close()
else:
if ConnectionPool._connection_pool:
ConnectionPool.put_connection(self._conn)
else:
self._conn.close()
self._cursor = None
self._conn = None

Expand All @@ -269,7 +269,7 @@ def get_connection(self):
}
if self.port:
conn_settings["port"] = self.port
if frappe.flags.in_install_db or frappe.flags.in_test:
if frappe.flags.in_install_db or frappe.flags.in_test or frappe.flags.in_drop_site:
conn = psycopg2.connect(**conn_settings)
else:
conn = ConnectionPool.get_connection(conn_settings)
Expand Down

0 comments on commit 5b931aa

Please sign in to comment.