[nautilus-python/nautilus-3.0] Fixes Bug 644399, Calculate the md5sum of the file contents, not the file name
- From: Adam Plumb <adamplumb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-python/nautilus-3.0] Fixes Bug 644399, Calculate the md5sum of the file contents, not the file name
- Date: Wed, 23 Mar 2011 19:16:30 +0000 (UTC)
commit 448527f216e86c125e4bdbbcc4dac4fc68be5fac
Author: Adam Plumb <adamplumb gmail com>
Date: Wed Mar 23 15:16:26 2011 -0400
Fixes Bug 644399, Calculate the md5sum of the file contents, not the file name
examples/md5sum-property-page.py | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/examples/md5sum-property-page.py b/examples/md5sum-property-page.py
index 017c3d9..00e192c 100644
--- a/examples/md5sum-property-page.py
+++ b/examples/md5sum-property-page.py
@@ -34,8 +34,13 @@ class MD5SumPropertyPage(gobject.GObject, Nautilus.PropertyPageProvider):
self.value_label = Gtk.Label()
self.hbox.pack_start(self.value_label, False, False, 0)
- md5sum = hashlib.md5(filename).hexdigest()
- self.value_label.set_text(md5sum)
+ md5sum = hashlib.md5()
+ with open(filename,'rb') as f:
+ for chunk in iter(lambda: f.read(8192), ''):
+ md5sum.update(chunk)
+ f.close()
+
+ self.value_label.set_text(md5sum.hexdigest())
self.value_label.show()
return Nautilus.PropertyPage(name="NautilusPython::md5_sum",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]