public inbox for [email protected]  
help / color / mirror / Atom feed
From: Pradip Parkale <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Subject: Re: [pgAdmin][RM6385]: Backup on a shared server doesn't seem to work
Date: Tue, 27 Apr 2021 11:48:39 +0530
Message-ID: <CAJ9T6Ssv=XrHatGXZJMMJ59aYRUfhRZtK6X1HqH2ipZDqCe8jA@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDcsUbtL4TybRrV9K1MvmSR-tfQVGnFBJxVgYCXJCEBb5w@mail.gmail.com>
References: <CAJ9T6SurWoKa6Z14F3wFGJtQbtFh+gCXt9vULSTciiR5AG4x1Q@mail.gmail.com>
	<CANxoLDdFqciV8JFVGnF-_VcwERteERChbKtEut4uruXQ_AfXmw@mail.gmail.com>
	<CAJ9T6SuPAJntFCgqjqGx4RHxr9d=5Ps3F+g9GcrED=mqGhO36Q@mail.gmail.com>
	<CANxoLDcsUbtL4TybRrV9K1MvmSR-tfQVGnFBJxVgYCXJCEBb5w@mail.gmail.com>

Hi Akshay,

Please find the updated patch. I have added more checks so that it will
pick the correct shared server.

On Thu, Apr 22, 2021 at 5:43 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Thu, Apr 22, 2021 at 2:37 PM Pradip Parkale <
> [email protected]> wrote:
>
>> Hi Akshay,
>>
>> Please find the updated patch. I did some modifications as some cases
>> were failing due to my initial changes.
>> Sorry for the inconvenience.
>>
>> On Wed, Apr 14, 2021 at 12:13 PM Akshay Joshi <
>> [email protected]> wrote:
>>
>>> Thanks, patch applied.
>>>
>>> On Tue, Apr 13, 2021 at 10:35 PM Pradip Parkale <
>>> [email protected]> wrote:
>>>
>>>> Hi Hackers,
>>>>
>>>> Please find the attached patch for #6385 Backup on a shared server
>>>> doesn't seem to work.
>>>>
>>>>
>>>>
>>>> --
>>>> Thanks & Regards,
>>>> Pradip Parkale
>>>> Software Engineer | EnterpriseDB Corporation
>>>>
>>>
>>>
>>> --
>>> *Thanks & Regards*
>>> *Akshay Joshi*
>>> *pgAdmin Hacker | Principal Software Architect*
>>> *EDB Postgres <http://edbpostgres.com>*
>>>
>>> *Mobile: +91 976-788-8246*
>>>
>>
>>
>> --
>> Thanks & Regards,
>> Pradip Parkale
>> Software Engineer | EnterpriseDB Corporation
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>


-- 
Thanks & Regards,
Pradip Parkale
Software Engineer | EnterpriseDB Corporation


Attachments:

  [application/octet-stream] RM6385_v3.patch (3.4K, 3-RM6385_v3.patch)
  download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 233ea07f8..105e90c8d 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -618,7 +618,7 @@ class ServerNode(PGChildNodeView):
             ),
         )
 
-    def delete_shared_server(self, server_name, gid):
+    def delete_shared_server(self, server_name, gid, osid):
         """
         Delete the shared server
         :param server_name:
@@ -626,7 +626,8 @@ class ServerNode(PGChildNodeView):
         """
         try:
             shared_server = SharedServer.query.filter_by(name=server_name,
-                                                         servergroup_id=gid)
+                                                         servergroup_id=gid,
+                                                         osid=osid)
             for s in shared_server:
                 get_driver(PG_DEFAULT_DRIVER).delete_manager(s.id)
                 db.session.delete(s)
@@ -662,7 +663,7 @@ class ServerNode(PGChildNodeView):
                     get_driver(PG_DEFAULT_DRIVER).delete_manager(s.id)
                     db.session.delete(s)
                 db.session.commit()
-                self.delete_shared_server(server_name, gid)
+                self.delete_shared_server(server_name, gid, sid)
                 QueryHistory.clear_history(current_user.id, sid)
 
             except Exception as e:
@@ -819,7 +820,7 @@ class ServerNode(PGChildNodeView):
                 if 'shared' in data and not data['shared']:
                     # Delete the shared server from DB if server
                     # owner uncheck shared property
-                    self.delete_shared_server(server.name, gid)
+                    self.delete_shared_server(server.name, gid, server.id)
                 if arg == 'sslcompression':
                     value = 1 if value else 0
                 self._update_server_details(server, sharedserver,
@@ -1879,7 +1880,7 @@ class ServerNode(PGChildNodeView):
             if server.shared and server.user_id != current_user.id:
                 shared_server = SharedServer.query.filter_by(
                     name=server.name, user_id=current_user.id,
-                    servergroup_id=gid).first()
+                    servergroup_id=gid, osid=server.id).first()
 
                 if shared_server is None:
                     return make_json_response(
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
index e07a6273a..69ddf6c39 100644
--- a/web/pgadmin/browser/server_groups/servers/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -282,15 +282,7 @@ def does_server_exists(sid, user_id):
     # **kwargs parameter can be added to function to filter with more
     # parameters.
     try:
-        if Server.query.filter_by(id=sid, user_id=user_id).first():
-            server = Server.query.filter_by(
-                id=sid, user_id=user_id
-            ).first()
-        else:
-            server = SharedServer.query.filter_by(
-                id=sid, user_id=user_id
-            ).first()
-
-        return True if server is not None else False
+        return True if Server.query.filter_by(
+            id=sid).first() is not None else False
     except Exception:
         return False


view thread (6+ 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], [email protected]
  Subject: Re: [pgAdmin][RM6385]: Backup on a shared server doesn't seem to work
  In-Reply-To: <CAJ9T6Ssv=XrHatGXZJMMJ59aYRUfhRZtK6X1HqH2ipZDqCe8jA@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