public inbox for [email protected]  
help / color / mirror / Atom feed
From: Surinder Kumar <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch]: Wrong listing of directories in File Manager in Windows Only.
Date: Mon, 5 Sep 2016 15:21:19 +0530
Message-ID: <CAM5-9D9+eq8auZ9SVOhU12xtTy29YaGSHitHfyTNfXocTK+gdw@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi

*Issue:*
FileManager: when Select File dialog is opened in query tool in Runtime
Mode, it was listing wrong directory. instead it should list drives such as
C:\, D:\, E:\ etc if no STORAGE_DIR path is set in config_local.py. This is
a regression of RM 1937.

*Solution:*
we do list drives, If platform is Windows and If self.dir is set to None,
but self.dir is set to empty string inside __init__ constructor. This is
the reason it wasn't listing drives.
I have taken care it in this patch and tested it for following platforms:
Windows,
Ubuntu and
Mac.

Please find attached patch and review.


Thanks,
Surinder Kumar


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] FileManager_show_drives_windows.patch (2.9K, 3-FileManager_show_drives_windows.patch)
  download | inline diff:
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 24e81dd..e262208 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -249,8 +249,7 @@ class Filemanager(object):
         )
         self.dir = get_storage_directory()
 
-        if ((self.dir is not None and isinstance(self.dir, list)) or
-           self.dir is None):
+        if (self.dir is not None and isinstance(self.dir, list)):
             self.dir = ""
 
     @staticmethod
@@ -568,7 +567,7 @@ class Filemanager(object):
                 'Code': 1
             }
 
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         # check if it's dir
         if old[-1] == '/':
             old = old[:-1]
@@ -620,7 +619,7 @@ class Filemanager(object):
                 'Code': 1
             }
 
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         orig_path = "{0}{1}".format(dir, path)
 
         err_msg = ''
@@ -653,7 +652,7 @@ class Filemanager(object):
                 'Code': 1
             }
 
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         err_msg = ''
         code = 1
         try:
@@ -674,14 +673,13 @@ class Filemanager(object):
             'Error': err_msg,
             'Code': code
         }
-
         return result
 
     def is_file_exist(self, path, name, req=None):
         """
         Checks whether given file exists or not
         """
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         err_msg = ''
         code = 1
         name = unquote(name)
@@ -733,7 +731,7 @@ class Filemanager(object):
                 'Code': 1
             }
 
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         newName = name
         if dir != "":
             newPath = dir + '/' + path + newName + '/'
@@ -775,7 +773,7 @@ class Filemanager(object):
                 'Code': 1
             }
 
-        dir = self.dir
+        dir = self.dir if self.dir is not None else ''
         orig_path = "{0}{1}".format(dir, path)
         name = path.split('/')[-1]
         content = open(orig_path, 'r')
diff --git a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
index baa71b1..8d891fd 100755
--- a/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
+++ b/web/pgadmin/misc/file_manager/templates/file_manager/js/utility.js
@@ -1488,8 +1488,7 @@ if (has_capability(data, 'upload')) {
         setTimeout(function() {}, 10000);
       },
       success: function(file, response) {
-        var response = jQuery.parseJSON(response),
-            data = response.data.result,
+        var data = response.data.result,
             $this = $(file.previewTemplate);
 
         if (data.Code == 0) {


view thread (2+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [pgAdmin4][Patch]: Wrong listing of directories in File Manager in Windows Only.
  In-Reply-To: <CAM5-9D9+eq8auZ9SVOhU12xtTy29YaGSHitHfyTNfXocTK+gdw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox