summaryrefslogtreecommitdiffstats
path: root/patches/opkg-utils-r4747/0020-opkg.py-computeFileMD5-only-when-we-have-fn-otherwis.patch
blob: d2963ee3911bdeb2507d3958d7622ca8a2b59a8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Thu, 29 Mar 2012 22:43:30 +0200
Subject: [PATCH] opkg.py: computeFileMD5 only when we have fn, otherwise fails
 to read None file

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 opkg.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/opkg.py b/opkg.py
index 6c39616..9daff9e 100644
--- a/opkg.py
+++ b/opkg.py
@@ -182,14 +182,17 @@ class Package:
 
     def _computeFileMD5(self):
         # compute the MD5.
-        f = open(self.fn, "rb")
-        sum = hashlib.md5()
-        while True:
-            data = f.read(1024)
-            if not data: break
-            sum.update(data)
-        f.close()
-        self.md5 = sum.hexdigest()
+        if not self.fn:
+            self.md5 = 'Unknown'
+        else:
+            f = open(self.fn, "rb")
+            sum = hashlib.md5()
+            while True:
+               data = f.read(1024)
+               if not data: break
+               sum.update(data)
+            f.close()
+            self.md5 = sum.hexdigest()
 
     def _get_file_size(self):
         if not self.fn: