#10807 NORM 11.2.0-: Can not copy pdf file to usb key

Zarro Boogs per Child bugtracker at laptop.org
Mon Apr 4 13:14:44 EDT 2011


#10807: Can not copy pdf file to usb key
------------------------------+---------------------------------------------
           Reporter:  erikos  |       Owner:  erikos                           
               Type:  defect  |      Status:  new                              
           Priority:  normal  |   Milestone:  11.2.0-M4                        
          Component:  sugar   |     Version:  Development build as of this date
         Resolution:          |    Keywords:                                   
        Next_action:  review  |    Verified:  0                                
Deployment_affected:          |   Blockedby:                                   
           Blocking:          |  
------------------------------+---------------------------------------------
Changes (by erikos):

 * cc: silbe (added)
  * next_action:  code => review


Comment:

 Proposed fixes:

 a) we should as well catch 'UnicodeDecodeError' and not write the metadata
 if that error occurs but still write the file itself.

 {{{
 diff --git a/src/jarabe/journal/model.py b/src/jarabe/journal/model.py
 index 9cea65e..c768e2a 100644
 --- a/src/jarabe/journal/model.py
 +++ b/src/jarabe/journal/model.py
 @@ -717,7 +717,7 @@ def _write_entry_on_external_device(metadata,
 file_path):

      try:
          metadata_json = simplejson.dumps(metadata_copy)
 -    except EnvironmentError:
 +    except (UnicodeDecodeError, EnvironmentError):
          logging.error('Could not convert metadata to json.')
      else:
          (fh, fn) = tempfile.mkstemp(dir=metadata['mountpoint'])
 }}}


 b) we can think about if we should omit data that can not be written to
 the json-format before, and as well if we should convert it to something
 writable before trying to write the json format (would need to detect and
 restore those entries then as well).

 Sascha, what do you think about it? I think (a) might be enough and the
 guidelines should maybe ask the activity authors to not use binary blobs
 for metadata, or base64 them before storing them in the metadata.

-- 
Ticket URL: <http://dev.laptop.org/ticket/10807#comment:3>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list