mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Use the user's full email address (not just the username part) as the basis for the storage directory name.. Fixes #3887
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
import os
|
||||
|
||||
from flask import url_for
|
||||
from flask import current_app, url_for
|
||||
from flask_security import current_user, login_required
|
||||
|
||||
|
||||
@@ -37,12 +37,28 @@ def get_storage_directory():
|
||||
if len(username) == 0 or username[0].isdigit():
|
||||
username = 'pga_user_' + username
|
||||
|
||||
storage_dir = os.path.join(
|
||||
# Figure out the old-style storage directory name
|
||||
old_storage_dir = os.path.join(
|
||||
storage_dir.decode('utf-8') if hasattr(storage_dir, 'decode')
|
||||
else storage_dir,
|
||||
username
|
||||
)
|
||||
|
||||
# Figure out the new style storage directory name
|
||||
storage_dir = os.path.join(
|
||||
storage_dir.decode('utf-8') if hasattr(storage_dir, 'decode')
|
||||
else storage_dir,
|
||||
current_user.email.replace('@', '_')
|
||||
)
|
||||
|
||||
# Rename an old-style storage directory, if the new style doesn't exist
|
||||
if os.path.exists(old_storage_dir) and not os.path.exists(storage_dir):
|
||||
current_app.logger.warning(
|
||||
'Renaming storage directory %s to %s.',
|
||||
old_storage_dir, storage_dir
|
||||
)
|
||||
os.rename(old_storage_dir, storage_dir)
|
||||
|
||||
if not os.path.exists(storage_dir):
|
||||
os.makedirs(storage_dir, int('700', 8))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user