[Sugar-devel] [PATCH Browse] Cancel a download if space is very tight SL #394
Martin Langhoff
martin.langhoff at gmail.com
Tue Sep 11 16:50:22 EDT 2012
On Tue, Sep 11, 2012 at 4:32 PM, Manuel Kaufmann <humitos at 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 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
Forget about check_available_space() and pretty messages to the user.
The real problem is hitting out-of-disk space. Can you run a test that
bypasses this code so it really gets to ENOSPC?
How does ENOSPC appear in Python?
Py documentation is pretty incomplete:
http://docs.python.org/library/exceptions.html#exceptions.IOError
This says IOError 28
http://stackoverflow.com/questions/6998083/python-causing-ioerror-errno-28-no-space-left-on-device-results-32766-h
I guess you'll have to try yourself. Try
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.
> 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')
I guess activity.get_activity_root() is in the main FS, not in a tmpfs. Luckily.
> That is something like (I guess):
> ~/.sugar/default/org.laptop.WebActivity/instance
Ah, cool. So it's in the same FS.
>
> 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)
> (...)
Oh, that expects a callback. If there is an exception, maybe we don't
get it on this side? :-(
> 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.
Being callback, its is probably going over dbus, so, ummm.
m
--
martin.langhoff at gmail.com
martin at laptop.org -- Software Architect - OLPC
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Sugar-devel
mailing list