Log archive post failure

This commit is contained in:
George Lacey 2022-10-05 16:24:05 +01:00
parent 2fb284a142
commit 71d911c660

View File

@ -7,6 +7,10 @@ from django.core.cache import cache as django_cache
from ..models import Repo, Label, Archive, Cache, Error, Location
from ..forms import RepoForm, ArchiveForm, ErrorForm, LocationForm, ToggleVisibility
import logging
logger = logging.getLogger(__file__)
@permission_required("borg.change_repo")
def toggle_visibility(request):
@ -63,6 +67,7 @@ def post_archive(request):
if request.method == 'POST':
form = ArchiveForm(request.POST)
if form.is_valid():
try:
cdata = form.cleaned_data
repo = get_object_or_404(Repo, label__label=cdata['label'])
@ -79,6 +84,8 @@ def post_archive(request):
archive = Archive(**archive_dict, repo=repo, cache=cache)
archive.save()
django_cache.clear()
except Exception:
logger.exception("Archive post failed")
return HttpResponseRedirect(reverse('index'))
else: