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.
This commit is contained in:
Surinder Kumar
2016-06-10 17:06:22 +01:00
committed by Dave Page
parent d9804ae2a2
commit 9e8e3fc787
4 changed files with 24 additions and 10 deletions

View File

@@ -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 = {

View File

@@ -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;