Ticket #4448: 0001-Calculate-the-md5-at-write-when-a-file-is-received-S.patch

File 0001-Calculate-the-md5-at-write-when-a-file-is-received-S.patch, 1.5 KB (added by godiard, 10 years ago)

Alternative solution

  • readactivity.py

    From 36a73c04fd100aae1a533099f771d8469060c33d Mon Sep 17 00:00:00 2001
    From: Gonzalo Odiard <godiard@gmail.com>
    Date: Thu, 28 Feb 2013 17:48:56 -0300
    Subject: [PATCH] Calculate the md5 at write when a file is received - SL #4448
    
    When a file is received after joining a colaboration session,
    need be saved in the journal, and we need calculate the md5 hash.
    
    Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
    ---
     readactivity.py | 5 ++++-
     1 file changed, 4 insertions(+), 1 deletion(-)
    
    diff --git a/readactivity.py b/readactivity.py
    index 1481056..c7a81aa 100644
    a b class ReadActivity(activity.Activity): 
    144144        self._fileserver = None
    145145        self._object_id = handle.object_id
    146146        self._toc_model = None
     147        self.filehash = None
    147148
    148149        self.connect('key-press-event', self._key_press_event_cb)
    149150        self.connect('key-release-event', self._key_release_event_cb)
    class ReadActivity(activity.Activity): 
    724725        self.metadata['Read_search'] = \
    725726                self._edit_toolbar._search_entry.props.text
    726727        self.metadata['activity'] = self.get_bundle_id()
    727         self.metadata['filehash'] = self.filehash
    728728
    729729        os.link(self._tempfile, file_path)
     730        if self.filehash is None:
     731            self.filehash = get_md5(file_path)
     732        self.metadata['filehash'] = self.filehash
    730733
    731734        if self._close_requested:
    732735            _logger.debug("Removing temp file %s because we will close",