Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNIJg-0007zh-7U for pgadmin-hackers@arkaria.postgresql.org; Wed, 13 Jul 2016 11:27:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bNIJf-00023Z-Ql for pgadmin-hackers@arkaria.postgresql.org; Wed, 13 Jul 2016 11:26:59 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bNIJS-0001pE-JR for pgadmin-hackers@postgresql.org; Wed, 13 Jul 2016 11:26:46 +0000 Received: from mail-it0-x22e.google.com ([2607:f8b0:4001:c0b::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bNIJP-0003Pa-0h for pgadmin-hackers@postgresql.org; Wed, 13 Jul 2016 11:26:45 +0000 Received: by mail-it0-x22e.google.com with SMTP id f6so17692990ith.1 for ; Wed, 13 Jul 2016 04:26:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pgadmin-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7gt1oyOj94uyUhckFid5al8Pk2wNnYWX1kyp1ERcC04=; b=bf+NuNTKqoPZtfUlTMqEE0wD3r5cmScFqoLDhtL+SjO7iq0xxtT5FyRUBaLEyohknJ 11mECWgFITvZrm139/106FTwPwkvIjqCV41jvarO675AjbOSEBxkeFal5+BiUpmlOhYj fTYNRNzFvVMQ1Mth8GsyG6w+VavnJMTwbuyGJxTLUA/4xj1N/u+/qfuQGRXVxhHKV7cI y0WlTvI6TlLsCkQH+LQrrrZdyS42sNqklZojybVXROprpAd/uYDjpmSUHUDlTN7jqVDn sV3d/a9hvMDDXAZmBjpGlDuHYQZgS9lqPKlljalSvF7OiA6z+4cJ5GbpyGjeRNaiRcdm 5P5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7gt1oyOj94uyUhckFid5al8Pk2wNnYWX1kyp1ERcC04=; b=XuIStiTOjQzGiVuo1lf29qOAwPpoI4E8JjBzlVQ8zhQjlW8d09tjrADpuwllmJgMcG SxV9YWE+eYL528eKFyUwn0w8I6t51/mluTxHq9BmJ+jYk4/pd+3w/WFFX8jMipGR6euS D41qTkDgY/BLkDE0RPPR8PGQ/RN3YobFUCmB1MBW0L6vdR8e5FHEhm0ND6/SOiD58cmj WYqaj9qR3SlZ5MbHwPCHXnorvM9CWmT98r/XgEnpVlQfIxh6mdnteXfRCGpXawNuInzd SzCwY1nG06DOQU6Yb6tpJHxgET+bEN7g7cdfbjAZnEE4Ep8GMYmfUlrnrqm6evGj1q4+ 2DKw== X-Gm-Message-State: ALyK8tINPPqoCZ1zogOvQ5FjIsSjn2iIBZwkA5ZFv/Yh1TVxbn2sBh5Vpbf88/lV2jW0Rn5vUJpNzCcAQKAoQQ== X-Received: by 10.36.207.214 with SMTP id y205mr23106487itf.37.1468409202126; Wed, 13 Jul 2016 04:26:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.208.97 with HTTP; Wed, 13 Jul 2016 04:26:41 -0700 (PDT) In-Reply-To: References: From: Dave Page Date: Wed, 13 Jul 2016 12:26:41 +0100 Message-ID: Subject: Re: [pgAdmin4][runtime]: Download feature in runtime To: Neel Patel Cc: pgadmin-hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org Thanks - applied. On Fri, Jul 8, 2016 at 7:17 AM, Neel Patel wrote: > Hi Dave, > > Please find attached patch file for the fix of crash and comment text. > Downloading cancel request was not handled properly and due to that > application was getting crashed. > > Do review it and let us know for comments. > > Thanks, > Neel Patel > > On Thu, Jul 7, 2016 at 2:13 PM, Dave Page wrote: >> >> Hi >> >> On Wed, Jul 6, 2016 at 9:12 AM, Neel Patel >> wrote: >> > Hi Dave, >> > >> > I have tried to fix most of the review comments. I have modified the >> > patch >> > on top of your changes. Please find attached updated patch file. >> > Find my comments inline. Can you please review and let us know your >> > feedback >> > ? >> >> That's definitely getting there; >> >> - Please make sure you follow the code style requirements, e.g. >> //Comment text >> >> - In your comments, typically you should refer to the user as "the >> user" not just "user". e.g. >> // Check that *the* user has given *a* valid file name or not >> >> The same applies to other cases where you miss the article >> (https://en.wikipedia.org/wiki/Article_(grammar)): >> // Check that *the* request contains the data download at client side >> >> NOTE: This isn't a criticism of you in particular - most of the team >> do this, I assume because it's more like the way you'd phrase things >> in Hindi. I just find myself correcting such mistakes regularly, and >> it's good for us all to continue to improve in general. >> >> - I was able to reproduce the crash again: >> 1) Open a tab, and go to the PostgreSQL download page on >> enterprisedb.com (linked from the pg.org site) >> 2) Start to download the 9.6b2 Win64 installer >> 3) Cancel the download >> 4) Click the link to download if your download didn't automatically >> start >> 5) Overwrite the existing file >> >> This results in: >> a) The progress bar flashes up and down weirdly on the second download >> b) The app crashes when the download completes: >> >> The program has unexpectedly finished. >> >> /Users/dpage/git/pgadmin4/build-pgAdmin4-Desktop_Qt_5_5_1_clang_64bit2-Debug/pgAdmin4.app/Contents/MacOS/pgAdmin4 >> crashed >> >> See the attached backtrace. >> >> Thanks! >> >> > On Fri, Jul 1, 2016 at 2:39 PM, Dave Page wrote: >> >> >> >> On Fri, Jul 1, 2016 at 5:43 AM, Neel Patel >> >> >> >> wrote: >> >> > Hi Dave, >> >> > >> >> > On Thu, Jun 30, 2016 at 7:31 PM, Dave Page wrote: >> >> >> >> >> >> Hi >> >> >> >> >> >> On Thu, Jun 30, 2016 at 10:42 AM, Neel Patel >> >> >> wrote: >> >> >> > Hi, >> >> >> > >> >> >> > Please find attached patch file for initial version of download >> >> >> > file >> >> >> > in >> >> >> > runtime application. >> >> >> >> >> >> I've attached an update with some improved messages, and setting the >> >> >> progress dialogue to be modal (seeing as we cannot have multiple >> >> >> downloads, and it's easy to lose the dialogue). >> >> >> >> >> >> > With this patch, we have implemented two features. >> >> >> > >> >> >> > Feature 1 :- Normal "Download file" from runtime application >> >> >> > >> >> >> > Previously "Download file" was not implemented in runtime >> >> >> > application. >> >> >> > With this patch file, we have handled Qt signal for download file >> >> >> > properly. >> >> >> >> >> >> This seems to work fine. I did get one crash (after I cancelled a >> >> >> download, then tried it again), but I couldn't reproduce that. >> >> > >> >> > >> >> > Okay. I will try to reproduce the issue and also i will try to review >> >> > the >> >> > code again if i can find something regrading crash. >> > >> > >> > I have tried to reproduce the crash but no luck. I have tried on Linux >> > and >> > Mac. >> > >> >> >> >> >> >> Thanks. >> >> >> >> > >> >> >> >> >> >> > Feature 2 :- "download" attribute support for 'a' tag for client >> >> >> > side >> >> >> > download >> >> >> > >> >> >> > As per our knowledge, webkit has not implemented the download >> >> >> > attribute >> >> >> > at >> >> >> > 'a' tag. >> >> >> > Currently it shows under development from below link. >> >> >> > >> >> >> > https://bugreports.qt.io/browse/QTBUG-47732 >> >> >> > >> >> >> > We did not found any signal in Qt for download attribute feature >> >> >> > but >> >> >> > to >> >> >> > implement this feature in runtime application, we added one >> >> >> > workaround >> >> >> > to >> >> >> > make it work with download CSV file. >> >> >> > >> >> >> > When we click on download buttons, we are getting Qt signal >> >> >> > "urlLinkClicked" >> >> >> > and in that url we are finding "data:text/csv" from encoded URL >> >> >> > generated >> >> >> > from sqleditor. Once we found that tag then we are decoding the >> >> >> > csv >> >> >> > data >> >> >> > and >> >> >> > writing to file. >> >> >> > >> >> >> > Is that right approach ? Should we add our own custom mime-type to >> >> >> > header ? >> >> >> > Let us know your thoughts on this feature. >> >> >> >> >> >> This doesn't work so well, for a number of reasons: >> >> >> >> >> >> 1) QT Creator is complaining that your regexp contains an invalid >> >> >> escape sequence (line 546). >> >> > >> >> > >> >> > I will fix. >> >> >> >> >> >> >> >> >> 2) The default file name seems to be the entire data blob. I would >> >> >> suggest making the file name "download.csv" if we don't know >> >> >> anything >> >> >> better. The "csv" part should be taken from the mime type (see >> >> >> below) >> >> >> >> >> >> 3) Should we handle all "data:" downloads in this way? Taking the >> >> >> file >> >> >> type and default extension from the mimetype offered. >> >> > >> >> > >> >> > We can handle all "data:" download. We will extract the filename and >> >> > extension from mime type. >> >> > As i know, Qt provides QUrlQuery class which will be useful to find >> >> > the >> >> > key >> >> > value pair. I will test and let you know. >> >> > >> >> > e.g. If we have header as below >> >> > >> >> > >> >> > >> >> > "data:text/csv;charset=utf-8;Content-disposition:attachment;filename=download.csv;" >> >> > >> >> > From the QurlQuery class we can query "filename" and "data:" and >> >> > accordingly >> >> > save the data to filename provided. >> >> > >> >> > Please suggest. >> >> >> >> Sounds good. >> >> >> >> >> 4) When I change the filename the data is properly saved, but then I >> >> >> get a confirmation message that still has the full data blob as the >> >> >> filename. >> > >> > >> > I found that it is due to different Qt version. You might be using Qt >> > 5.5. >> > In Qt 5.5, we are getting "download" signal and for Qt < 5.5 we are >> > getting >> > "urlLinkClicked" signal for client side data download. >> > We have fixed the issue for all Qt version. Let me know if you can still >> > able to reproduce the issue. >> > >> >> >> >> >> >> >> >> 5) It somehow seems to have let me save files with forward slashes >> >> >> in >> >> >> the name. See attachment. >> > >> > >> > Fixed. >> > >> >> > >> >> > >> >> > I think we should not ask for "Save as" dialog. If there is no key >> >> > found >> >> > of >> >> > "filename" in encodedURI then we should create the file >> >> > "download.csv" >> >> > in >> >> > user's download directory and save the csv data. >> >> >> >> Well we can get the extension from the mimetype in that instance, but >> >> otherwise I agree with the naming. I do think we need a Save As >> >> dialogue, as the user should be able to choose the location for the >> >> file (and rename it). We should also remember the last save location >> >> for convenience. >> > >> > >> > Fixed. >> > >> >> >> >> >> >> >> 6) I get all sorts of weird redrawing on the screen when downloading >> >> >> a >> >> >> data blob. I suspect it's because the filename (which is still the >> >> >> entire data blob) is shown on the progress dialogue. >> >> >> >> > >> > >> > Fixed. >> > >> >> >> >> > >> >> > I will try to fix as per above comments and submit the patch again. >> >> > Let us know for any misunderstanding. >> >> >> >> Cool, thanks. >> >> >> >> >> >> -- >> >> Dave Page >> >> Blog: http://pgsnake.blogspot.com >> >> Twitter: @pgsnake >> >> >> >> EnterpriseDB UK: http://www.enterprisedb.com >> >> The Enterprise PostgreSQL Company >> > >> > >> >> >> >> -- >> Dave Page >> Blog: http://pgsnake.blogspot.com >> Twitter: @pgsnake >> >> EnterpriseDB UK: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company > > -- Dave Page Blog: http://pgsnake.blogspot.com Twitter: @pgsnake EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-hackers