X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Fdbconn.py;h=3806e31e2d09c9922c58014e9c0462d13e0a368b;hb=a93b9774a23c42560c713d0cfe7d5c37548f1b6a;hp=bdb223e23cb148429b505da228ecb14a61a52496;hpb=0d651b1c6eefaabfe8be90355ea181a5e275bd9d;p=dak.git diff --git a/daklib/dbconn.py b/daklib/dbconn.py index bdb223e2..3806e31e 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -508,17 +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. + 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) + 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') @@ -3283,7 +3288,7 @@ class DBConn(object): mapper(BinContents, self.tbl_bin_contents, properties = dict( binary = relation(DBBinary, - backref=backref('contents', lazy='dynamic')), + backref=backref('contents', lazy='dynamic', cascade='all')), file = self.tbl_bin_contents.c.file)) ## Connection functions @@ -3301,8 +3306,14 @@ class DBConn(object): connstr = "postgres:///%s" % cnf["DB::Name"] if cnf["DB::Port"] and cnf["DB::Port"] != "-1": connstr += "?port=%s" % cnf["DB::Port"] - - self.db_pg = create_engine(connstr, echo=self.debug) + if not cnf.has_key('DB::PoolSize'): + cnf['DB::PoolSize'] = '5' + if not cnf.has_key('DB::MaxOverflow'): + cnf['DB::MaxOverflow'] = '10' + + self.db_pg = create_engine(connstr, echo=self.debug, + pool_size=int(cnf['DB::PoolSize']), + max_overflow=int(cnf['DB::MaxOverflow'])) self.db_meta = MetaData() self.db_meta.bind = self.db_pg self.db_smaker = sessionmaker(bind=self.db_pg,