Fix file selection on Windows. Fixes #1319
1) Unable to select sql file through query tool on windows OS. In file_manager.js, we are stripping initial slash '/' from the path obtained, but we should not strip if it is full path like 'c:/path/to/dir/filename.ext' 2) Handle directory path if STORAGE_DIR is None. Proper checks are added.pull/3/head
parent
d9804ae2a2
commit
9e8e3fc787
|
@ -245,7 +245,7 @@ class Filemanager(object):
|
|||
)
|
||||
self.dir = get_storage_directory()
|
||||
|
||||
if isinstance(self.dir, list):
|
||||
if self.dir is not None and isinstance(self.dir, list):
|
||||
self.dir = ""
|
||||
|
||||
@staticmethod
|
||||
|
@ -507,6 +507,8 @@ class Filemanager(object):
|
|||
"""
|
||||
|
||||
path = unquote(path)
|
||||
if self.dir is None:
|
||||
self.dir = ""
|
||||
orig_path = "{0}{1}".format(self.dir, path)
|
||||
user_dir = path
|
||||
thefile = {
|
||||
|
|
|
@ -138,7 +138,9 @@ define([
|
|||
sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
|
||||
}
|
||||
var newFile = $('.currentpath').val() + sel_file;
|
||||
newFile = newFile.substr(1);
|
||||
if (newFile.indexOf('/') == 0) {
|
||||
newFile = newFile.substr(1);
|
||||
}
|
||||
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:storage_dialog', newFile);
|
||||
}
|
||||
removeTransId(trans_id);
|
||||
|
@ -249,7 +251,9 @@ define([
|
|||
sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
|
||||
}
|
||||
var newFile = $('.currentpath').val() + sel_file;
|
||||
newFile = newFile.substr(1);
|
||||
if (newFile.indexOf('/') == 0) {
|
||||
newFile = newFile.substr(1);
|
||||
}
|
||||
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:select_file', newFile);
|
||||
}
|
||||
removeTransId(trans_id);
|
||||
|
@ -360,7 +364,9 @@ define([
|
|||
sel_file = $('.fileinfo tbody tr.selected td p span').attr('title');
|
||||
}
|
||||
var newFile = $('.currentpath').val() + sel_file;
|
||||
newFile = newFile.substr(1);
|
||||
if (newFile.indexOf('/') == 0) {
|
||||
newFile = newFile.substr(1);
|
||||
}
|
||||
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:select_folder', newFile);
|
||||
}
|
||||
removeTransId(trans_id);
|
||||
|
@ -468,8 +474,10 @@ define([
|
|||
$('.replace_file .btn_yes').click(function(self) {
|
||||
$('.replace_file, .fm_dimmer').hide();
|
||||
var selected_item = $('.allowed_file_types .create_input input[type="text"]').val(),
|
||||
sel_item = $('.currentpath').val() + selected_item,
|
||||
newFile = sel_item.substr(1);
|
||||
newFile = $('.currentpath').val() + selected_item;
|
||||
if (newFile.indexOf('/') == 0) {
|
||||
newFile = newFile.substr(1);
|
||||
}
|
||||
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:create_file', newFile);
|
||||
$('.file_manager_create_cancel').trigger('click');
|
||||
});
|
||||
|
@ -509,7 +517,9 @@ define([
|
|||
if (closeEvent.button.text == "{{ _('Create') }}") {
|
||||
var selected_item = $('.allowed_file_types .create_input input[type="text"]').val();
|
||||
var newFile = $('.currentpath').val() + selected_item;
|
||||
newFile = newFile.substr(1);
|
||||
if (newFile.indexOf('/') == 0) {
|
||||
newFile = newFile.substr(1);
|
||||
}
|
||||
if(!_.isUndefined(selected_item) && selected_item !== '' && this.is_file_exist()) {
|
||||
this.replace_file();
|
||||
closeEvent.cancel = true;
|
||||
|
|
|
@ -1117,6 +1117,8 @@ def load_file():
|
|||
|
||||
# retrieve storage directory path
|
||||
storage_manager_path = get_storage_directory()
|
||||
if storage_manager_path is None:
|
||||
storage_manager_path = ""
|
||||
|
||||
# generate full path of file
|
||||
file_path = os.path.join(
|
||||
|
|
|
@ -61,11 +61,11 @@ def init_app(app):
|
|||
if storage_dir and not os.path.isdir(storage_dir):
|
||||
if os.path.exists(storage_dir):
|
||||
raise Exception(
|
||||
'The value specified for as the storage directory is not a directory!'
|
||||
'The path specified for the storage directory is not a directory.'
|
||||
)
|
||||
os.makedirs(storage_dir, int('700', 8))
|
||||
|
||||
if not os.access(storage_dir, os.W_OK | os.R_OK):
|
||||
if storage_dir and not os.access(storage_dir, os.W_OK | os.R_OK):
|
||||
raise Exception(
|
||||
'The user does not have permission to read, write on the specified storage directory!'
|
||||
'The user does not have permission to read and write to the specified storage directory.'
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue