Commit f5c8b829 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Added nodes check on 'deleteStoarge()' method.

parent fb7dbdd6
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -427,10 +427,27 @@ class DbConnector(object):
    def deleteStorage(self, storageId):
        """Deletes a storage point."""
        if self.conn:
            self.cursor.execute("""
                SELECT count(*) > 0 AS res 
                FROM Node 
                WHERE location_id IN 
                (SELECT location_id 
                 FROM storage s 
                 JOIN location l 
                 ON s.storage_id = l.storage_src_id 
                 WHERE storage_src_id = %s);
                """,
                (storageId,))

            if self.cursor.fetchall()[0]["res"]:
                return False
            else:
                self.cursor.execute("""
                    DELETE FROM storage 
                    WHERE storage_id = %s;
                    """,
                    (storageId,))
                self.conn.commit()
                return True