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

Manuel Kaufmann humitos at gmail.com
Tue Sep 11 16:32:14 EDT 2012


On Tue, Sep 11, 2012 at 8:03 PM, Gonzalo Odiard <gonzalo at 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 what I get here:

 * http://bugs.sugarlabs.org/ticket/394#comment:7

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 is raised. Maybe we can write the portion of code here to
raise that exception before show the ModelAlert and if it's not
managed we can call the ModelAlert.

[1] sugar/src/jarabe/journal/journalactivity.py L336
[2] sugar/src/jarabe/journal/journalactivity.py L274
[3] sugar/src/jarabe/journal/journalactivity.py L265

> The browser is downloading the file in a temporary place and later moving to
> the journal or
> is creating a object in the journal while downloading?

The file is downloaded in a temporary directory and then copied to the Journal:

 temp_path = os.path.join(activity.get_activity_root(), 'instance')
 fd, self._dest_path = tempfile.mkstemp(dir=temp_path,
                                    suffix=download.get_suggested_filename(),
                                    prefix='tmp')

That is something like (I guess):
~/.sugar/default/org.laptop.WebActivity/instance

When the download finishes:

(...)
self.dl_jobject = datastore.create()
(...)
datastore.write(self.dl_jobject,
                            transfer_ownership=True,
                            reply_handler=self.__internal_save_cb,
                            error_handler=self.__internal_error_cb,
                            timeout=360)
(...)

> Is important to know if the control in the journal will work or not.

but, we are updating a Journal entry every time that the progress of
the download changes to show the "progress bar" in the Journal:
browse/downloadmanager.py L90

def __progress_change_cb(self, download, something):
        progress = self._download.get_progress()
        self.dl_jobject.metadata['progress'] = str(int(progress * 100))
        datastore.write(self.dl_jobject)

so, we are updating a model inside the datastore... If we had the
ENOSPC exception we could manage it there. I insist this goes in a
different ticket and a different patch.

See you,

-- 
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