# HG changeset patch # User neko259 # Date 2017-03-04 17:12:41 # Node ID 2272bd987ca0aa46b9131dd6c68f658cc9efc963 # Parent 7fb52044f84e2b3b8ecf09be3734a4590f8bb27c Allow deleting attachments with their files already deleted diff --git a/boards/signals.py b/boards/signals.py --- a/boards/signals.py +++ b/boards/signals.py @@ -126,10 +126,16 @@ def rebuild_refmap(instance, **kwargs): def delete_file(instance, **kwargs): if instance.is_internal(): file = MEDIA_ROOT + instance.file.name - os.remove(file) + try: + os.remove(file) + except FileNotFoundError: + pass if instance.mimetype in FILE_TYPES_IMAGE: for size in THUMB_SIZES: file_name_parts = instance.file.name.split('.') thumb_file = MEDIA_ROOT + '{}.{}x{}.{}'.format(file_name_parts[0], size[0], size[1], file_name_parts[1]) - os.remove(thumb_file) + try: + os.remove(thumb_file) + except FileNotFoundError: + pass diff --git a/boards/views/tag_gallery.py b/boards/views/tag_gallery.py --- a/boards/views/tag_gallery.py +++ b/boards/views/tag_gallery.py @@ -18,7 +18,8 @@ class TagGalleryView(BaseBoardView, Pagi page = int(request.GET.get('page', 1)) params = dict() - tag = get_object_or_404(Tag, name=tag_name) + tag_alias = get_object_or_404(TagAlias, name=tag_name) + tag = tag_alias.parent params['tag'] = tag paginator = get_paginator(tag.get_images(), IMAGES_PER_PAGE, current_page=page)