remove duplicate dist dirs

This commit is contained in:
dave 2019-05-04 19:55:55 -07:00
parent a91d0c85c5
commit 0f86483a4c
1 changed files with 9 additions and 1 deletions

View File

@ -266,12 +266,20 @@ class PipWeb(object):
yield self.tpl.get_template("pypi/repo.html") \ yield self.tpl.get_template("pypi/repo.html") \
.render(repo=repo, .render(repo=repo,
dists=db().query(PipPackage).filter(PipPackage.repo == repo).order_by(PipPackage.dist).all()) dists=self._get_dists(repo))
return return
yield self.tpl.get_template("pypi/root.html") \ yield self.tpl.get_template("pypi/root.html") \
.render(repos=db().query(PipRepo).order_by(PipRepo.name).all()) .render(repos=db().query(PipRepo).order_by(PipRepo.name).all())
def _get_dists(self, repo):
lastdist = None
for dist in db().query(PipPackage).filter(PipPackage.repo == repo).order_by(PipPackage.dist).all():
if lastdist and dist.dist == lastdist:
continue
yield dist
lastdist = dist.dist
def handle_download(self, reponame, distname, filename): def handle_download(self, reponame, distname, filename):
repo = get_repo(db(), reponame, create_ok=False) repo = get_repo(db(), reponame, create_ok=False)
pkg = db().query(PipPackage).filter(PipPackage.repo == repo, PipPackage.fname == filename).first() pkg = db().query(PipPackage).filter(PipPackage.repo == repo, PipPackage.fname == filename).first()