Просмотр исходного кода

Merge pull request #9256 from kkthxbye-code/fix-9122

Fix #9122 - Clear the cache when running the upgrade script
Jeremy Stretch 3 лет назад
Родитель
Сommit
b172ae65d2
2 измененных файлов с 16 добавлено и 0 удалено
  1. 11 0
      netbox/extras/management/commands/clearcache.py
  2. 5 0
      upgrade.sh

+ 11 - 0
netbox/extras/management/commands/clearcache.py

@@ -0,0 +1,11 @@
+from django.core.cache import cache
+from django.core.management.base import BaseCommand
+
+
+class Command(BaseCommand):
+    """Command to clear the entire cache."""
+    help = 'Clears the cache.'
+
+    def handle(self, *args, **kwargs):
+        cache.clear()
+        self.stdout.write('Cache has been cleared.', ending="\n")

+ 5 - 0
upgrade.sh

@@ -108,6 +108,11 @@ COMMAND="python3 netbox/manage.py clearsessions"
 echo "Removing expired user sessions ($COMMAND)..."
 eval $COMMAND || exit 1
 
+# Clear the cache
+COMMAND="python3 netbox/manage.py clearcache"
+echo "Clearing the cache ($COMMAND)..."
+eval $COMMAND || exit 1
+
 if [ -v WARN_MISSING_VENV ]; then
   echo "--------------------------------------------------------------------"
   echo "WARNING: No existing virtual environment was detected. A new one has"