+# vim: ai ts=4 sts=4 sw=4
#!/usr/bin/env python
"""
def dumprepos(self):
# FIXME: use a trigger to indicate if *anything at all* has changed
+ allrepos = {}
curs = self.db.cursor()
curs.execute("SELECT name,anonymous,web,description,initialclone,(SELECT min(first_name) FROM repository_permissions AS rp LEFT JOIN auth_user AS au ON au.username=rp.userid WHERE rp.level=2 AND rp.repository=r.repoid) FROM repositories AS r WHERE approved ORDER BY name")
f = open("%s.tmp" % self.conf.get("paths", "gitweblist"), "w")
for name, anon, web, description, initialclone, owner in curs:
+ allrepos[name] = 1
# Check if this repository exists at all
if not os.path.isdir("%s/repos/%s" % (self.conf.get("paths", "githome"), name)):
# Does not exist, let's initialize a new one
os.chmod("%s.tmp" % self.conf.get("paths", "gitweblist"), 0644)
os.rename("%s.tmp" % self.conf.get("paths", "gitweblist"), self.conf.get("paths", "gitweblist"))
+ # Now remove any repositories that have been deleted
+ for d in os.listdir("%s/repos/" % self.conf.get("paths", "githome")):
+ if not allrepos.has_key(d):
+ print "Removing repository %s" % d
+ try:
+ shutil.rmtree("%s/repos/%s" % (self.conf.get("paths", "githome"), d))
+ except Exception,e:
+ print "FAIL: unable to remove directory: %s" % e
+
if __name__ == "__main__":
c = ConfigParser.ConfigParser()
c.read("pggit.settings")