[Sugar-devel] [PATCH] Journal: Enable saving metadata in external device - OLPC#10717

Gonzalo Odiard gonzalo at laptop.org
Fri Jun 24 08:21:00 EDT 2011


Ok pushed.

Gonzalo

On Fri, Jun 24, 2011 at 8:38 AM, Simon Schampijer <simon at schampijer.de>wrote:

> Thanks for the patch Gonzalo. The patch looks good and works well, tested
> here.
>
> Acked-By: Simon Schampijer <simon at laptop.org>
>
> Regards,
>   Simon
>
>
> On 06/17/2011 04:20 PM, godiard at sugarlabs.org wrote:
>
>> From: Gonzalo Odiard<godiard at gmail.com>
>>
>> This patch enable saving metadata and renaming files in device
>> with write permission.
>> There are code to avoid break if the user change the title and other
>> properties, like description, tags or favorites, because changing
>> the title, the files used to save the meatata change the name too.
>>
>> Signed-off-by: Gonzalo Odiard<gonzalo at laptop.org>
>> ---
>>  src/jarabe/journal/**expandedentry.py |   20 ++++++++++++++++++--
>>  src/jarabe/journal/listview.py      |    3 ---
>>  src/jarabe/journal/model.py         |    6 ++++--
>>  3 files changed, 22 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/jarabe/journal/**expandedentry.py b/src/jarabe/journal/*
>> *expandedentry.py
>> index fe2f320..d293694 100644
>> --- a/src/jarabe/journal/**expandedentry.py
>> +++ b/src/jarabe/journal/**expandedentry.py
>> @@ -18,6 +18,7 @@ import logging
>>  from gettext import gettext as _
>>  import StringIO
>>  import time
>> +import os
>>
>>  import hippo
>>  import cairo
>> @@ -406,7 +407,14 @@ class ExpandedEntry(hippo.CanvasBox)**:
>>              needs_update = True
>>
>>          if needs_update:
>> -            model.write(self._metadata, update_mtime=False)
>> +            if self._metadata.get('**mountpoint', '/') == '/':
>> +                model.write(self._metadata, update_mtime=False)
>> +            else:
>> +                old_file_path = os.path.join(self._metadata['**
>> mountpoint'],
>> +                        model.get_file_name(old_title,
>> +                        self._metadata['mime_type']))
>> +                model.write(self._metadata, file_path=old_file_path,
>> +                        update_mtime=False)
>>
>>          self._update_title_sid = None
>>
>> @@ -420,7 +428,15 @@ class ExpandedEntry(hippo.CanvasBox)**:
>>              self._metadata['keep'] = 0
>>          else:
>>              self._metadata['keep'] = 1
>> -        model.write(self._metadata, update_mtime=False)
>> +
>> +        if self._metadata.get('**mountpoint', '/') == '/':
>> +            model.write(self._metadata, update_mtime=False)
>> +        else:
>> +            f_path = os.path.join(self._metadata['**mountpoint'],
>> +                    model.get_file_name(self._**metadata['title'],
>> +                    self._metadata['mime_type']))
>> +            model.write(self._metadata, file_path=f_path,
>> +                    update_mtime=False)
>>
>>          keep_icon.props.keep = self.get_keep()
>>
>> diff --git a/src/jarabe/journal/listview.**py
>> b/src/jarabe/journal/listview.**py
>> index 1bc8f8a..78e109a 100644
>> --- a/src/jarabe/journal/listview.**py
>> +++ b/src/jarabe/journal/listview.**py
>> @@ -328,9 +328,6 @@ class BaseListView(gtk.Bin):
>>          self._scroll_position = self.tree_view.props.**
>> vadjustment.props.value
>>          logging.debug('ListView.__map_**cb %r', self._scroll_position)
>>
>> -        is_editable = self._query.get('mountpoints', '') == '/'
>> -        self.cell_title.props.editable = is_editable
>> -
>>      def _is_query_empty(self):
>>          # FIXME: This is a hack, we shouldn't have to update this every
>> time
>>          # a new search term is added.
>> diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
>> index fd25681..2be2bde 100644
>> --- a/src/jarabe/journal/model.py
>> +++ b/src/jarabe/journal/model.py
>> @@ -782,5 +782,7 @@ def get_unique_file_name(mount_**point, file_name):
>>
>>
>>  def is_editable(metadata):
>> -    mountpoint = metadata.get('mountpoint', '/')
>> -    return mountpoint == '/'
>> +    if metadata.get('mountpoint', '/') == '/':
>> +        return True
>> +    else:
>> +        return os.access(metadata['**mountpoint'], os.W_OK)
>>
>
> ______________________________**_________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.**org <Sugar-devel at lists.sugarlabs.org>
> http://lists.sugarlabs.org/**listinfo/sugar-devel<http://lists.sugarlabs.org/listinfo/sugar-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20110624/ca07b9e0/attachment-0001.html>


More information about the Sugar-devel mailing list