Fixed shared storage file accessibility issues in import/export servers and cloud deployment. #5014

This commit is contained in:
Nikhil Mohite 2023-03-24 16:27:02 +05:30 committed by GitHub
parent c8945883c1
commit b429a38176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 6 deletions

View File

@ -549,7 +549,6 @@ def get_shared_storage_list():
Return the shared storage list after checking all required keys are present
or not in config. This is for server mode only.
"""
shared_storage_config = []
shared_storage_list = []
restricted_shared_storage_list = []
if config.SERVER_MODE:

View File

@ -664,8 +664,13 @@ export default function FileManager({params, closeModal, onOK, onCancel, sharedS
setSelectedSS(fmUtilsObj.config.options.storage_folder);
}
openDir(params?.path, fmUtilsObj.config.options.storage_folder);
params?.path && fmUtilsObj.setLastVisitedDir(params?.path, selectedSS);
let tempPath = params?.path;
if (params?.dialog_type == 'storage_dialog' && (!params?.path?.includes('/') || !params?.path?.includes('\\'))) {
tempPath = '/';
}
openDir(tempPath, fmUtilsObj.config.options.storage_folder);
(params?.dialog_type != 'storage_dialog' && params?.path) && fmUtilsObj.setLastVisitedDir(params?.path, selectedSS);
};
init();
setTimeout(()=>{

View File

@ -22,7 +22,9 @@ from threading import Lock
from .paths import get_storage_directory
from .preferences import Preferences
from pgadmin.utils.constants import UTILITIES_ARRAY, USER_NOT_FOUND
from pgadmin.utils.constants import UTILITIES_ARRAY, USER_NOT_FOUND, \
MY_STORAGE, ACCESS_DENIED_MESSAGE
from pgadmin.utils.ajax import make_json_response
from pgadmin.model import db, User, ServerGroup, Server
from urllib.parse import unquote
@ -269,8 +271,26 @@ def filename_with_file_manager_path(_file, create_file=False,
Returns:
Filename to use for backup with full path taken from preference
"""
# Set file manager directory from preference
storage_dir = get_storage_directory()
# retrieve storage directory path
last_storage = Preferences.module('file_manager').preference(
'last_storage').get()
if last_storage != MY_STORAGE:
selDirList = [sdir for sdir in current_app.config['SHARED_STORAGE']
if sdir['name'] == last_storage]
selectedDir = selDirList[0] if len(
selDirList) == 1 else None
if selectedDir:
if selectedDir['restricted_access'] and \
not current_user.has_role("Administrator"):
return make_json_response(success=0,
errormsg=ACCESS_DENIED_MESSAGE,
info='ACCESS_DENIED',
status=403)
storage_dir = get_storage_directory(
shared_storage=last_storage)
else:
storage_dir = get_storage_directory()
from pgadmin.misc.file_manager import Filemanager
Filemanager.check_access_permission(