Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-18 Thread Manuel Kaufmann
On Mon, Sep 17, 2012 at 7:40 PM, James Cameron qu...@laptop.org wrote: I've no other comments about the patch. Thanks for your comments. I'm about to send a new patch. -- Kaufmann Manuel Blog: http://humitos.wordpress.com/ Porfolio: http://fotos.mkaufmann.com.ar/ PyAr:

[Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-17 Thread Manuel Kaufmann
It checks if there will be more than MIN_DISKFREE_AFTER_DOWNLOAD (20Mb) after downloading the file. If not, Browse will cancel the download process before starting it and an Alert will be shown to the user to inform this situation. Signed-off-by: Manuel Kaufmann humi...@gmail.com ---

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-17 Thread James Cameron
On Mon, Sep 17, 2012 at 08:24:18AM -0300, Manuel Kaufmann wrote: It checks if there will be more than MIN_DISKFREE_AFTER_DOWNLOAD (20Mb) after downloading the file. If not, Browse will cancel the download process before starting it and an Alert will be shown to the user to inform this

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Manuel Kaufmann
On Tue, Sep 11, 2012 at 10:27 PM, Martin Langhoff martin.langh...@gmail.com wrote: - During the webkit download -- most probable stage where you'll hit it. How does Webkit behave? Does Browse need to do anything? I'm attaching an example that downloads a file with WebKit. I tried it setting

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Manuel Kaufmann
On Tue, Sep 11, 2012 at 10:27 PM, Martin Langhoff martin.langh...@gmail.com wrote: - During datastore.write() -- I truly believe that the datastore.write() call doesn't literally make a copy of the file -- should just create/update the hardlink and associated metadata (including progress

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Martin Langhoff
On Wed, Sep 12, 2012 at 7:50 AM, Manuel Kaufmann humi...@gmail.com wrote: I'm attaching an example that downloads a file with WebKit. I tried it setting up a tmpfs with 1Mb as you suggested and aftert that, I ran this script. WebKit tells us about the insufficient space on the disk by raising

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Manuel Kaufmann
On Wed, Sep 12, 2012 at 9:21 AM, Martin Langhoff martin.langh...@gmail.com wrote: That's very good handling on webkit's side. And does it remove the file? IOWs, when you get the signal, what do you see in the tmpfs? Is there a file filling it, or has the file been removed? Oh, sorry. I forgot

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Martin Langhoff
On Wed, Sep 12, 2012 at 8:20 AM, Manuel Kaufmann humi...@gmail.com wrote: OK. I was taking a look at the datastore source code and I understood that the file is copied, using the traditional way and when the copy finishes the source file is unlinked. Ouch! I haven't reviewed the code (have to

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Martin Langhoff
On Wed, Sep 12, 2012 at 8:24 AM, Manuel Kaufmann humi...@gmail.com wrote: On Wed, Sep 12, 2012 at 9:21 AM, Martin Langhoff martin.langh...@gmail.com wrote: That's very good handling on webkit's side. And does it remove the file? IOWs, when you get the signal, what do you see in the tmpfs? Is

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-12 Thread Gonzalo Odiard
On Wed, Sep 12, 2012 at 9:26 AM, Martin Langhoff martin.langh...@gmail.comwrote: On Wed, Sep 12, 2012 at 8:20 AM, Manuel Kaufmann humi...@gmail.com wrote: OK. I was taking a look at the datastore source code and I understood that the file is copied, using the traditional way and when the

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Manuel Kaufmann
On Mon, Sep 10, 2012 at 9:49 PM, Martin Langhoff martin.langh...@gmail.com wrote: Here, get the content-length... and compare with the free bytes (plus some padding, say, 15%). Maybe we still want to preserve a minimum disk space. For example: don't let a download put you below 50MB or 10MB

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Martin Langhoff
On Tue, Sep 11, 2012 at 9:01 AM, Manuel Kaufmann humi...@gmail.com wrote: If we are going to use this approach, I have to change the logic about where I should check this. +200. I hadn't realized this. The main two things you absolutely need are - check at the start of the download that it'll

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Hal Murray
martin.langh...@gmail.com said: Checking in the progress bar... it's optional. Up to you if you want to check there _as well_. Sometimes, you don't know at the start how big a download will be. In that case, if you want to stop before filling up the disk, you have to check often-enough

[Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Manuel Kaufmann
It checks if there will be more than MIN_DISKFREE_AFTER_DOWNLOAD (50Mb) after downloading the file. If not, Browse will cancel the download process before starting it and an Alert will be shown to the user to inform this situation. Signed-off-by: Manuel Kaufmann humi...@gmail.com ---

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Gonzalo Odiard
On Tue, Sep 11, 2012 at 4:23 PM, Manuel Kaufmann humi...@gmail.com wrote: On Tue, Sep 11, 2012 at 1:37 PM, Martin Langhoff martin.langh...@gmail.com wrote: - check at the start of the download that it'll fit (with X room to spare) This is done in the new version of the patch that I sent.

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Manuel Kaufmann
On Tue, Sep 11, 2012 at 8:03 PM, Gonzalo Odiard gonz...@laptop.org wrote: Can you try almost fill the xo and copy a big file with the journal from a pendrive? I remember a big message in the screen when this happen, and will point you to the code. Yes, I've already try that and I commented

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Martin Langhoff
On Tue, Sep 11, 2012 at 4:32 PM, Manuel Kaufmann humi...@gmail.com wrote: I didn't find an exception raised by Sugar when this happens. The check is done[1] when a new Model is created[2] or updated[3] inside the Journal, and if there are less than 50Mb a ModelAlert is shown but no exception

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Manuel Kaufmann
On Tue, Sep 11, 2012 at 8:50 PM, Martin Langhoff martin.langh...@gmail.com wrote: mkdir /tmp/foo sudo mount -t tmpfs -o size=1M none /tmp/foo Now write there to a file in /tmp/foo to see what happens, exactly. This is what I got: [olpc@xo-07-30-50 ~]$ mkdir /tmp/foo [olpc@xo-07-30-50 ~]$

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread Martin Langhoff
On Tue, Sep 11, 2012 at 9:07 PM, Manuel Kaufmann humi...@gmail.com wrote: This is what I got: [olpc@xo-07-30-50 ~]$ mkdir /tmp/foo [olpc@xo-07-30-50 ~]$ sudo mount -t tmpfs -o size=1M none /tmp/foo [olpc@xo-07-30-50 ~]$ python Python 2.7.3 (default, Apr 30 2012, 23:07:00) [GCC 4.7.0

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-11 Thread James Cameron
On Wed, Sep 12, 2012 at 01:07:29AM +, Manuel Kaufmann wrote: So, we should handle this exception inside the Journal Activity, when an object is created or updated. ... For your interest, open_log_file in activityfactory.py in sugar-toolkit.git contains a handling of ENOSPC. (What it does

[Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Manuel Kaufmann
If there are less than 50Mb free on the Hard Disk the downloading process is canceled and this is informed to the user via an Alert. Signed-off-by: Manuel Kaufmann humi...@gmail.com --- downloadmanager.py | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Martin Langhoff
On Mon, Sep 10, 2012 at 5:33 PM, Manuel Kaufmann humi...@gmail.com wrote: If there are less than 50Mb free on the Hard Disk the downloading process is canceled and this is informed to the user via an Alert. Perhaps it is a stupid question but... in many HTTP requests you get the size of the

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Martin Langhoff
On Mon, Sep 10, 2012 at 5:49 PM, Martin Langhoff martin.langh...@gmail.com wrote: Perhaps it is a stupid question but... in many HTTP requests you get s/question/suggestion/ m -- martin.langh...@gmail.com mar...@laptop.org -- Software Architect - OLPC - ask interesting questions - don't

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Manuel Kaufmann
On Mon, Sep 10, 2012 at 9:49 PM, Martin Langhoff martin.langh...@gmail.com wrote: Perhaps it is a stupid question but... in many HTTP requests you get the size of the transfer in the HTTP headers, in the form of the Content-Length header. I didn't follow this approach because of this comment:

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Martin Langhoff
On Mon, Sep 10, 2012 at 6:02 PM, Manuel Kaufmann humi...@gmail.com wrote: On Mon, Sep 10, 2012 at 9:49 PM, Martin Langhoff martin.langh...@gmail.com wrote: Perhaps it is a stupid question but... in many HTTP requests you get the size of the transfer in the HTTP headers, in the form of the

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Manuel Kaufmann
On Mon, Sep 10, 2012 at 10:13 PM, Martin Langhoff martin.langh...@gmail.com wrote: It does make sense to declare a minimum buffer, but you have good reliably info in content-length, use it! Ok. I will go for that :) -- Kaufmann Manuel Blog: http://humitos.wordpress.com/ Porfolio:

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread James Cameron
Some users pay for data by volume. I don't think that cancelling a download is the right approach. It should be paused, giving the user a chance to clean up. Also, I agree with Martin that additional use of Content-Length headers can be made, to warn the user against trying a download larger

Re: [Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394

2012-09-10 Thread Martin Langhoff
On Mon, Sep 10, 2012 at 6:39 PM, James Cameron qu...@laptop.org wrote: Some users pay for data by volume. I don't think that cancelling a download is the right approach. It should be paused, giving the user a chance to clean up. Rather complex -- I haven't seen any webbrowser correctly