Удаление ортофотоплана

This commit is contained in:
zakhy 2025-05-12 11:38:38 +07:00
parent 563dc5ab29
commit 5122beb959

View File

@ -1,5 +1,6 @@
import logging
import os.path
import shutil
import subprocess
import sys
import traceback
@ -104,7 +105,7 @@ class OrthoCreateView(CreateView):
]
try:
subprocess.run(cmd, check=True)
subprocess.run(cmd, check=False)
except subprocess.CalledProcessError:
logger.error(traceback.format_exc())
@ -166,7 +167,10 @@ class OrthoDeleteView(DeleteView):
) -> HttpResponseRedirect | HttpResponse:
try:
ortho: Ortho = self.get_object()
path = ortho.tiles_path
response: HttpResponseRedirect = super().delete(request, *args, **kwargs)
rm_len = len(path) - 16
shutil.rmtree(path[:rm_len], ignore_errors=True)
logger.info(
f"Удален ортофтоплан: {ortho.name} (ID: {ortho.pk}) "
f"пользователем: {request.user} (ID: {request.user.pk})"