X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=6827891d555445adfc357f1a1addfcd1c1a1f28b;hb=9ca85bf3b8790a8d9e1daa4a9dd70019f55f6e08;hp=5bff4186df00dba323e449a482bc90c1f6eba93a;hpb=33430ab640a257ba1227a740cbfb808bfcc94ff9;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 5bff4186..6827891d 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -508,19 +508,26 @@ 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 ' ' 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|') + anything_yielded = False for member in tar.getmembers(): if member.isfile(): + 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 + anything_yielded = True + if not anything_yielded: + yield ' ' tar.close() dpkg.stdout.close() dpkg.wait()