mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-24 09:40:21 -06:00
Ensure that the original file format should be retained when saving the same file in SQL editor. Fixes #3767
This commit is contained in:
parent
87d08de3a0
commit
43e127de31
@ -23,6 +23,7 @@ Housekeeping
|
||||
Bug fixes
|
||||
*********
|
||||
|
||||
| `Issue #3767 <https://redmine.postgresql.org/issues/3767>`_ - Ensure that the original file format should be retained when saving the same file in SQL editor.
|
||||
| `Issue #4810 <https://redmine.postgresql.org/issues/4810>`_ - Fixed an issue where the user is not able to save the new row if the table is empty.
|
||||
| `Issue #5490 <https://redmine.postgresql.org/issues/5490>`_ - Make the runtime configuration dialog non-modal.
|
||||
| `Issue #5632 <https://redmine.postgresql.org/issues/5632>`_ - Ensure that the user will be able to modify the start value of the Identity column.
|
||||
|
@ -313,6 +313,9 @@ def save_show_hidden_file_option(trans_id):
|
||||
class Filemanager(object):
|
||||
"""FileManager Class."""
|
||||
|
||||
# Stores list of dict for filename & its encoding
|
||||
loaded_file_encoding_list = []
|
||||
|
||||
def __init__(self, trans_id):
|
||||
self.trans_id = trans_id
|
||||
self.patherror = encode_json(
|
||||
@ -1088,6 +1091,10 @@ class Filemanager(object):
|
||||
# Check if string is binary
|
||||
is_binary = is_binary_string(file_data)
|
||||
|
||||
# Store encoding for future use
|
||||
Filemanager.loaded_file_encoding_list.\
|
||||
append({os.path.basename(filename): enc})
|
||||
|
||||
except IOError as ex:
|
||||
status = False
|
||||
# we don't want to expose real path of file
|
||||
|
@ -1250,10 +1250,20 @@ def save_file():
|
||||
file_path.lstrip('/').lstrip('\\')
|
||||
)
|
||||
|
||||
# Get value for encoding if file is already loaded to SQL editor
|
||||
def get_file_encoding_of_loaded_file(file_name):
|
||||
encoding = 'utf-8'
|
||||
for ele in Filemanager.loaded_file_encoding_list:
|
||||
if file_name in ele:
|
||||
encoding = ele[file_name]
|
||||
return encoding
|
||||
|
||||
enc = get_file_encoding_of_loaded_file(os.path.basename(file_path))
|
||||
|
||||
if hasattr(str, 'decode'):
|
||||
file_content = file_data['file_content']
|
||||
else:
|
||||
file_content = file_data['file_content'].encode()
|
||||
file_content = file_data['file_content'].encode(enc)
|
||||
|
||||
# write to file
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user