Commit 6b3df0e0 authored by Claude Paroz's avatar Claude Paroz

Delete stats when they exist no more on the file system (Fixes #657685)

parent c5381a1e
......@@ -470,7 +470,8 @@ class Branch(models.Model):
command = "msgmerge --previous -o %(outpo)s %(pofile)s %(potfile)s"
stats_with_ext_errors = Statistics.objects.filter(branch=self, domain=dom, information__type__endswith='-ext')
langs_with_ext_errors = [stat.language.locale for stat in stats_with_ext_errors]
for lang, pofile in dom.get_lang_files(self.co_path()):
dom_langs = dom.get_lang_files(self.co_path())
for lang, pofile in dom_langs:
outpo = os.path.join(self.output_dir(dom.dtype), dom.potbase() + "." + self.name + "." + lang + ".po")
if not force and changed_status in (utils.NOT_CHANGED, utils.CHANGED_ONLY_FORMATTING) and os.access(outpo, os.R_OK) \
......@@ -520,6 +521,10 @@ class Branch(models.Model):
figstats=fig_stats)
for err in langstats['errors']:
stat.information_set.add(Information(type=err[0], description=err[1]))
# Delete stats for unexisting langs
Statistics.objects.filter(branch=self, domain=dom
).exclude(models.Q(language__isnull=True) | models.Q(language__locale__in=[dl[0] for dl in dom_langs])
).delete()
# Check if doap file changed
if self.is_head() and self.file_changed("%s.doap" % self.module.name):
update_doap_infos(self.module)
......
......@@ -82,6 +82,8 @@ class ModuleTestCase(TestCase):
self.assertEqual(self.branch.get_vcs_web_url(), "http://git.gnome.org/browse/gnome-hello/")
def testBranchStats(self):
lang = Language.objects.create(name='xxx', locale='xxx')
ghost_stat = Statistics.objects.create(branch=self.branch, domain=self.mod.domain_set.get(name='po'), language=lang)
# Check stats
self.branch.update_stats(force=True)
fr_po_stat = Statistics.objects.get(branch=self.branch, domain__name='po', language__locale='fr')
......@@ -91,6 +93,7 @@ class ModuleTestCase(TestCase):
self.assertEqual(fr_po_stat.po_url(), u"/POT/gnome-hello.master/gnome-hello.master.fr.po")
self.assertEqual(fr_po_stat.pot_url(), u"/POT/gnome-hello.master/gnome-hello.master.pot")
self.assertEqual(fr_doc_stat.po_url(), u"/POT/gnome-hello.master/docs/gnome-hello-help.master.fr.po")
self.assertRaises(Statistics.DoesNotExist, Statistics.objects.get, pk=ghost_stat.pk)
def testCreateAndDeleteBranch(self):
Branch.checkout_on_creation = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment