[nautilus-python] Fixes Bug #644399, Calculate the md5sum of the file contents, not the file name



commit 259e4934254a1215b5d8a7c12deb8ff1c2baf781
Author: Adam Plumb <adamplumb gmail com>
Date:   Wed Mar 23 15:14:02 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 271c18a..49f0a7d 100644
--- a/examples/md5sum-property-page.py
+++ b/examples/md5sum-property-page.py
@@ -34,8 +34,13 @@ class MD5SumPropertyPage(nautilus.PropertyPageProvider):
         self.value_label = gtk.Label()
         self.hbox.pack_start(self.value_label)
 
-        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("NautilusPython::md5_sum",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]