Skip to content

Commit

Permalink
fix(cleanup-migration): fail gracefully in new container
Browse files Browse the repository at this point in the history
  • Loading branch information
czosel authored and anehx committed Jan 6, 2022
1 parent 3f8a819 commit 8a93339
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions document_merge_service/api/migrations/0004_cleanup_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
from django.db import migrations
from django.conf import settings

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)


def cleanup_files(apps, schema_editor):
Template = apps.get_model("api", "Template")
Expand All @@ -16,7 +13,10 @@ def cleanup_files(apps, schema_editor):
with os.scandir(settings.MEDIA_ROOT) as files:
for f in files:
if not f.path in used_files and os.path.isfile(f.path):
os.remove(f.path)
try:
os.remove(f.path)
except Exception as e:
pass # ignore permission issues when running this in a fresh container


class Migration(migrations.Migration):
Expand Down

0 comments on commit 8a93339

Please sign in to comment.