[Sugar-devel] Not enough space adventure

Manuel Kaufmann humitos at gmail.com
Tue Sep 18 08:42:05 EDT 2012


Hello people,

I'd like to comment what I've been doing these days regarding
"Downloading a file with Browse without having enough space to keep
it".

 * http://bugs.sugarlabs.org/ticket/394

We where discussing about this last week[1] and we found the "root"
issue of this problem: Sugar is not handling ENOSPC error. This could
cause some problems at boot time when the XO is restarted, but as we
discussed[2], Linux has made some improvement on this side and it
seems that it recovers without problem (we need more testing here, I
think).

So, there are different problems to manage here:
 1. What are we going to do when ENOSPC is reached?

I'm not sure about this point and I think we have to discuss what to
do here and how implement this. There is an important ticket for this

 * http://bugs.sugarlabs.org/ticket/2317

 2. How are we going to avoid ENOSCP?

Well, this is the topic where I focused my work. Trying to avoid
reaching ENOSCP. A good place to do some work is Browse (but this work
include some extra modifications in other components as well) because
it's the main activity that generate big files by downloading them
from the internet. So, Gonzalo and I were discussing about a good
implementation regarding this and we found, at least, an alternative.
It consists in:

 - remove the annoying check of free space
(sugar3.datastore.datastore.SPACE_THRESHOLD = 50Mb at the moment) from
the Journal Activity that shows all the time the ModalAlert saying
"Your Journal is full. Please remove some entries" every time and it
doesn't allow you to do another things.

 - create a signal inside sugar-toolkit-gtk3 datastore that is emitted
when free space is behind
"sugar3.datastore.datastore.SPACE_THRESHOLD". This check is done every
time a model is updated or created by the datastore.

 - this signal can be connected from every activity that wants to
handle this situation. For example in Browse we are cancelling the
download in progress when we get that signal

 - the same signal is captured in Journal Activity to show the
ModalAlert saying "Your Journal is full" that was shown before

 - create a helper function in sugar-toolkit-gtk3 activity Activity
class to check if there is enough space to keep a new file (Browse
uses this before downloading a file from the internet). I decided to
put this helper inside Activity class because I think it could be
useful for many activities.

 - compare (in Browse) the Content-Length with the free space
available + SPACE_THRESHOLD (this is done by the helper function) and
decide if the download is going to take place or not

These are all the patches involved on this change:

 * http://patchwork.sugarlabs.org/patch/1749/
 * http://patchwork.sugarlabs.org/patch/1750/
 * http://patchwork.sugarlabs.org/patch/1751/
 * http://patchwork.sugarlabs.org/patch/1752/
 * http://patchwork.sugarlabs.org/patch/1753/

Thanks, comments and suggestions are welcomed.

[1] http://lists.sugarlabs.org/archive/sugar-devel/2012-September/039516.html
[2] http://lists.sugarlabs.org/archive/sugar-devel/2012-September/039576.html

PD: Gonzalo, please, add whatever thing that I missed.

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/


More information about the Sugar-devel mailing list