]> git.decadent.org.uk Git - dak.git/blobdiff - daklib/dbconn.py
mhy, das kruemelmonster
[dak.git] / daklib / dbconn.py
index c7ecdc189cb3125b132fb350fb4756193ce655ca..fb2cc3b0d6a91808df8d393fd41edf884dc922dc 100755 (executable)
@@ -508,19 +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 either utf-8 or
-        iso8859-1 encoding.
+        the path names are normalized after converting them from either utf-8
+        or iso8859-1 encoding. It yields the string ' <EMPTY PACKAGE>' if the
+        package does not contain any regular file.
         '''
         fullpath = self.poolfile.fullpath
         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():
+            if not member.isdir():
+                name = normpath(member.name)
+                # enforce proper utf-8 encoding
                 try:
-                    name = member.name.decode('utf-8')
+                    name.decode('utf-8')
                 except UnicodeDecodeError:
-                    name = member.name.decode('iso8859-1')
-                yield normpath(name)
+                    name = name.decode('iso8859-1').encode('utf-8')
+                yield name
         tar.close()
         dpkg.stdout.close()
         dpkg.wait()
@@ -3001,8 +3004,9 @@ class DBConn(object):
             table = Table(table_name, self.db_meta, autoload=True)
             setattr(self, 'tbl_%s' % table_name, table)
 
-        # bin_contents needs special attention until update #41 has been
-        # applied
+        # bin_contents needs special attention until the SERIAL type is
+        # correctly detected and the workaround has been removed; see comment
+        # above
         self.tbl_bin_contents = Table('bin_contents', self.db_meta, \
             Column('file', Text, primary_key = True),
             Column('binary_id', Integer, ForeignKey('binaries.id'), \
@@ -3312,7 +3316,7 @@ class DBConn(object):
             engine_args['pool_size'] = int(cnf['DB::PoolSize'])
         if cnf.has_key('DB::MaxOverflow'):
             engine_args['max_overflow'] = int(cnf['DB::MaxOverflow'])
-        if sa_major_version >= 0.6 and cnf.has_key('DB::Unicode') and \
+        if sa_major_version == '0.6' and cnf.has_key('DB::Unicode') and \
             cnf['DB::Unicode'] == 'false':
             engine_args['use_native_unicode'] = False