Jul 14 - Using CDN - Phase 2a
This commit is contained in:
@@ -1335,15 +1335,12 @@ def delete(inspection_id):
|
||||
db.session.delete(inspection)
|
||||
db.session.commit()
|
||||
|
||||
# Remove orphaned photo files from the active storage backend — best-effort.
|
||||
# (Also fixes the previous double-'static' path that normalized to
|
||||
# app/static/static/... and never actually deleted anything.)
|
||||
from app.utils import storage
|
||||
for rel_path in photo_paths:
|
||||
abs_path = os.path.normpath(
|
||||
os.path.join(current_app.config['UPLOAD_FOLDER'], '..', 'static', rel_path)
|
||||
)
|
||||
try:
|
||||
if os.path.isfile(abs_path):
|
||||
os.remove(abs_path)
|
||||
except OSError:
|
||||
pass
|
||||
storage.delete(rel_path)
|
||||
|
||||
current_app.logger.info(
|
||||
'INSPECTION DELETED | id=%s | facility="%s" | template="%s" | '
|
||||
|
||||
@@ -1009,15 +1009,10 @@ def delete(issue_id):
|
||||
db.session.delete(issue)
|
||||
db.session.commit()
|
||||
|
||||
# Remove orphaned photo files — best-effort, never block on failure
|
||||
static_folder = current_app.root_path
|
||||
# Remove orphaned photo files from the active storage backend — best-effort.
|
||||
from app.utils import storage
|
||||
for rel_path in photo_paths:
|
||||
abs_path = os.path.normpath(os.path.join(static_folder, 'static', rel_path))
|
||||
try:
|
||||
if os.path.isfile(abs_path):
|
||||
os.remove(abs_path)
|
||||
except OSError:
|
||||
pass
|
||||
storage.delete(rel_path)
|
||||
|
||||
current_app.logger.info(
|
||||
'ISSUE DELETED | id=%s | severity=%s | area=%s | facility=%s | deleted_by=%s',
|
||||
|
||||
Reference in New Issue
Block a user