prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pootle_fs not expiring cache_keys
  When a project uses pootle FS, stats are not updated. We have to manually call `pootle flush_cache --lru --django-cache` to update it manually.
  
  </issue>
  <code>
  [start of pootle/apps/pootle_revision/receivers.py]
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 from django.db.models.signals import post_save, pre_delete
  10 from django.dispatch import receiver
  11 
  12 from pootle.core.delegate import revision_updater
  13 from pootle_app.models import Directory
  14 from pootle_data.models import StoreData
  15 from pootle_store.models import Store
  16 
  17 
  18 @receiver(post_save, sender=StoreData)
  19 def handle_storedata_save(**kwargs):
  20     revision_updater.get(Store)(
  21         context=kwargs["instance"].store).update(keys=["stats", "checks"])
  22 
  23 
  24 @receiver(post_save, sender=Directory)
  25 def handle_directory_save(**kwargs):
  26     if kwargs.get("created"):
  27         return
  28     revision_updater.get(Directory)(
  29         context=kwargs["instance"]).update(keys=["stats", "checks"])
  30 
  31 
  32 @receiver(pre_delete, sender=Directory)
  33 def handle_directory_delete(**kwargs):
  34     revision_updater.get(Directory)(
  35         context=kwargs["instance"].parent).update(keys=["stats", "checks"])
  36
  [end of pootle/apps/pootle_revision/receivers.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pootle/apps/pootle_revision/receivers.py b/pootle/apps/pootle_revision/receivers.py
  --- a/pootle/apps/pootle_revision/receivers.py
  +++ b/pootle/apps/pootle_revision/receivers.py
  @@ -23,10 +23,12 @@
   
   @receiver(post_save, sender=Directory)
   def handle_directory_save(**kwargs):
  -    if kwargs.get("created"):
  -        return
  +    context = (
  +        kwargs["instance"].parent
  +        if kwargs.get("created")
  +        else kwargs["instance"])
       revision_updater.get(Directory)(
  -        context=kwargs["instance"]).update(keys=["stats", "checks"])
  +        context=context).update(keys=["stats", "checks"])
   
   
   @receiver(pre_delete, sender=Directory)
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_revision/receivers.py b/pootle/apps/pootle_revision/receivers.py\n--- a/pootle/apps/pootle_revision/receivers.py\n+++ b/pootle/apps/pootle_revision/receivers.py\n@@ -23,10 +23,12 @@\n \n @receiver(post_save, sender=Directory)\n def handle_directory_save(**kwargs):\n-    if kwargs.get(\"created\"):\n-        return\n+    context = (\n+        kwargs[\"instance\"].parent\n+        if kwargs.get(\"created\")\n+        else kwargs[\"instance\"])\n     revision_updater.get(Directory)(\n-        context=kwargs[\"instance\"]).update(keys=[\"stats\", \"checks\"])\n+        context=context).update(keys=[\"stats\", \"checks\"])\n \n \n @receiver(pre_delete, sender=Directory)\n", "issue": "pootle_fs not expiring cache_keys\nWhen a project uses pootle FS, stats are not updated. We have to manually call `pootle flush_cache --lru --django-cache` to update it manually.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nfrom django.db.models.signals import post_save, pre_delete\nfrom django.dispatch import receiver\n\nfrom pootle.core.delegate import revision_updater\nfrom pootle_app.models import Directory\nfrom pootle_data.models import StoreData\nfrom pootle_store.models import Store\n\n\n@receiver(post_save, sender=StoreData)\ndef handle_storedata_save(**kwargs):\n    revision_updater.get(Store)(\n        context=kwargs[\"instance\"].store).update(keys=[\"stats\", \"checks\"])\n\n\n@receiver(post_save, sender=Directory)\ndef handle_directory_save(**kwargs):\n    if kwargs.get(\"created\"):\n        return\n    revision_updater.get(Directory)(\n        context=kwargs[\"instance\"]).update(keys=[\"stats\", \"checks\"])\n\n\n@receiver(pre_delete, sender=Directory)\ndef handle_directory_delete(**kwargs):\n    revision_updater.get(Directory)(\n        context=kwargs[\"instance\"].parent).update(keys=[\"stats\", \"checks\"])\n", "path": "pootle/apps/pootle_revision/receivers.py"}]}