Fixed an issue where Import Export not working when using pgpassfile. #6165

pull/6518/head
Kevapo 2023-06-29 07:43:50 +02:00 committed by GitHub
parent cbeacf890d
commit 944b614431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -18,7 +18,7 @@ from flask_security import login_required, current_user
from pgadmin.misc.bgprocess.processes import BatchProcess, IProcessDesc
from pgadmin.utils import PgAdminModule, get_storage_directory, html, \
fs_short_path, document_dir, IS_WIN, does_utility_exist, \
filename_with_file_manager_path
filename_with_file_manager_path, get_complete_file_path
from pgadmin.utils.ajax import make_json_response, bad_request, unauthorized
from config import PG_DEFAULT_DRIVER
@ -56,6 +56,7 @@ class IEMessage(IProcessDesc):
Defines the message shown for the import/export operation.
"""
def __init__(self, *_args, **io_params):
self.sid = io_params['sid']
self.schema = io_params['schema']
@ -102,7 +103,7 @@ class IEMessage(IProcessDesc):
host_port_str = ''
if s.host:
host_port_str = '({0}:{1})'.format(
s.host, s.port)if s.port else '{0}'.format(s.host)
s.host, s.port) if s.port else '{0}'.format(s.host)
return "{0} {1}".format(s.name, host_port_str)
@ -349,6 +350,14 @@ def create_import_export_job(sid):
if value is None:
del env[key]
# Export PGPASSFILE to work with PGPASSFILE authenthification
if manager.connection_params \
and isinstance(manager.connection_params, dict):
if 'passfile' in manager.connection_params \
and manager.connection_params['passfile']:
env['PGPASSFILE'] = get_complete_file_path(
manager.connection_params['passfile'])
p.set_env_variables(server, env=env)
p.start()
jid = p.id