]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
Reap zombie children in scan_contents().
[dak.git] / daklib / dbconn.py
index aab025136f0b35139f6f1ef590d52b11ea921cb8..04823061814912e5da33d084acaeb5cc1ecdf45f 100755 (executable)
@@ -508,18 +508,22 @@ class DBBinary(ORMObject):
     def scan_contents(self):
         '''
         Yields the contents of the package. Only regular files are yielded and
-        the path names are normalized after converting them from iso8859-1
-        encoding.
+        the path names are normalized after converting them from either utf-8 or
+        iso8859-1 encoding.
         '''
         fullpath = self.poolfile.fullpath
-        debdata = Popen(['dpkg-deb', '--fsys-tarfile', fullpath],
-            stdout = PIPE).stdout
-        tar = TarFile.open(fileobj = debdata, mode = 'r|')
+        dpkg = Popen(['dpkg-deb', '--fsys-tarfile', fullpath], stdout = PIPE)
+        tar = TarFile.open(fileobj = dpkg.stdout, mode = 'r|')
         for member in tar.getmembers():
             if member.isfile():
-                yield normpath(member.name.decode('iso8859-1'))
+                try:
+                    name = member.name.decode('utf-8')
+                except UnicodeDecodeError:
+                    name = member.name.decode('iso8859-1')
+                yield normpath(name)
         tar.close()
-        debdata.close()
+        dpkg.stdout.close()
+        dpkg.wait()
 
 __all__.append('DBBinary')