mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-12 09:01:57 -06:00
Ensure that Backup and Restore should work on shared servers. Fixes #6385
This commit is contained in:
parent
4ee40e348c
commit
cb7bcaf939
@ -38,3 +38,4 @@ Bug fixes
|
||||
| `Issue #6367 <https://redmine.postgresql.org/issues/6367>`_ - Fixed an issue where the Save button is enabled by default when open the table's properties dialog on PG 9.5.
|
||||
| `Issue #6375 <https://redmine.postgresql.org/issues/6375>`_ - Fixed an issue where users are unable to see data of the partitions using the View/Edit data option.
|
||||
| `Issue #6376 <https://redmine.postgresql.org/issues/6376>`_ - Fixed an issue where a connection warning should be displayed on the user clicks on explain or explain analyze and the database server is disconnected from the browser tree.
|
||||
| `Issue #6385 <https://redmine.postgresql.org/issues/6385>`_ - Ensure that Backup and Restore should work on shared servers.
|
||||
|
@ -346,7 +346,7 @@ class ServerModule(sg.ServerGroupPluginModule):
|
||||
host=data.host,
|
||||
hostaddr=data.hostaddr,
|
||||
port=data.port,
|
||||
maintenance_db=None,
|
||||
maintenance_db=data.maintenance_db,
|
||||
username=None,
|
||||
save_password=0,
|
||||
ssl_mode=data.ssl_mode,
|
||||
|
@ -12,7 +12,7 @@ from ipaddress import ip_address
|
||||
|
||||
from pgadmin.utils.crypto import encrypt, decrypt
|
||||
import config
|
||||
from pgadmin.model import db, Server
|
||||
from pgadmin.model import db, Server, SharedServer
|
||||
|
||||
|
||||
def is_valid_ipaddress(address):
|
||||
@ -283,8 +283,15 @@ def does_server_exists(sid, user_id):
|
||||
# **kwargs parameter can be added to function to filter with more
|
||||
# parameters.
|
||||
try:
|
||||
return True if Server.query.filter_by(
|
||||
id=sid, user_id=user_id
|
||||
).first() is not None else False
|
||||
if Server.query.filter_by(id=sid, user_id=user_id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=user_id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=user_id
|
||||
).first()
|
||||
|
||||
return True if server is not None else False
|
||||
except Exception:
|
||||
return False
|
||||
|
@ -24,7 +24,7 @@ from pgadmin.utils import PgAdminModule, get_storage_directory, html, \
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.misc.bgprocess import escape_dquotes_process_arg
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
|
||||
@ -115,10 +115,15 @@ class BackupMessage(IProcessDesc):
|
||||
self.cmd += cmd_arg(arg)
|
||||
|
||||
def get_server_details(self):
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
s = Server.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
if Server.query.filter_by(id=self.sid,
|
||||
user_id=current_user.id).first():
|
||||
s = Server.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
s = SharedServer.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
@ -417,9 +422,14 @@ def create_backup_objects_job(sid):
|
||||
return bad_request(errormsg=str(e))
|
||||
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
@ -521,9 +531,14 @@ def check_utility_exists(sid, backup_obj_type):
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
|
@ -20,7 +20,7 @@ from pgadmin.utils.ajax import bad_request, make_json_response
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
|
||||
MODULE_NAME = 'maintenance'
|
||||
@ -209,8 +209,14 @@ def create_maintenance_job(sid, did):
|
||||
index_name = get_index_name(data)
|
||||
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
server = Server.query.filter_by(
|
||||
id=sid).first()
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
@ -300,9 +306,18 @@ def check_utility_exists(sid):
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
# server = Server.query.filter_by(
|
||||
# id=sid, user_id=current_user.id
|
||||
# ).first()
|
||||
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
|
@ -22,7 +22,7 @@ from pgadmin.utils import PgAdminModule, get_storage_directory, html, \
|
||||
from pgadmin.utils.ajax import make_json_response, bad_request
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
from pgadmin.model import Server
|
||||
from pgadmin.model import Server, SharedServer
|
||||
from pgadmin.utils.constants import MIMETYPE_APP_JS
|
||||
|
||||
# set template path for sql scripts
|
||||
@ -88,9 +88,15 @@ class RestoreMessage(IProcessDesc):
|
||||
|
||||
def get_server_details(self):
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
s = Server.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
if Server.query.filter_by(id=self.sid,
|
||||
user_id=current_user.id).first():
|
||||
s = Server.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
s = SharedServer.query.filter_by(
|
||||
id=self.sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
from pgadmin.utils.driver import get_driver
|
||||
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||
@ -209,10 +215,14 @@ def _connect_server(sid):
|
||||
:param sid: Server ID.
|
||||
:return: if not error occurred then return connection data.
|
||||
"""
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
server = Server.query.filter_by(
|
||||
id=sid
|
||||
).first()
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
@ -466,9 +476,15 @@ def check_utility_exists(sid):
|
||||
Returns:
|
||||
None
|
||||
"""
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
# Fetch the server details like hostname, port, roles etc
|
||||
if Server.query.filter_by(id=sid, user_id=current_user.id).first():
|
||||
server = Server.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
else:
|
||||
server = SharedServer.query.filter_by(
|
||||
id=sid, user_id=current_user.id
|
||||
).first()
|
||||
|
||||
if server is None:
|
||||
return make_json_response(
|
||||
|
Loading…
Reference in New Issue
Block a user