posts: fix exception in expunge method.

Fix regression in 7c63ac8db. Posts no longer have an association with
uploads, so expunge failed when it tried to destroy the associated upload.
This commit is contained in:
evazion
2022-02-05 22:35:05 -06:00
parent 1032a60d4b
commit 9dd1afbedd

View File

@@ -41,7 +41,6 @@ class Post < ApplicationRecord
belongs_to :uploader, :class_name => "User", :counter_cache => "post_upload_count" belongs_to :uploader, :class_name => "User", :counter_cache => "post_upload_count"
belongs_to :parent, class_name: "Post", optional: true belongs_to :parent, class_name: "Post", optional: true
has_one :media_asset, -> { active }, foreign_key: :md5, primary_key: :md5 has_one :media_asset, -> { active }, foreign_key: :md5, primary_key: :md5
has_one :upload, :dependent => :destroy
has_one :artist_commentary, :dependent => :destroy has_one :artist_commentary, :dependent => :destroy
has_one :pixiv_ugoira_frame_data, class_name: "PixivUgoiraFrameData", foreign_key: :md5, primary_key: :md5 has_one :pixiv_ugoira_frame_data, class_name: "PixivUgoiraFrameData", foreign_key: :md5, primary_key: :md5
has_one :vote_by_current_user, -> { active.where(user_id: CurrentUser.id) }, class_name: "PostVote" # XXX using current user here is wrong has_one :vote_by_current_user, -> { active.where(user_id: CurrentUser.id) }, class_name: "PostVote" # XXX using current user here is wrong
@@ -1123,7 +1122,7 @@ class Post < ApplicationRecord
:image_height, :tag_count, :has_children, :has_active_children, :image_height, :tag_count, :has_children, :has_active_children,
:is_pending, :is_flagged, :is_deleted, :is_banned, :is_pending, :is_flagged, :is_deleted, :is_banned,
:last_comment_bumped_at, :last_commented_at, :last_noted_at, :last_comment_bumped_at, :last_commented_at, :last_noted_at,
:uploader_ip_addr, :uploader, :approver, :parent, :upload, :uploader_ip_addr, :uploader, :approver, :parent,
:artist_commentary, :flags, :appeals, :notes, :comments, :children, :artist_commentary, :flags, :appeals, :notes, :comments, :children,
:approvals, :replacements, :pixiv_ugoira_frame_data :approvals, :replacements, :pixiv_ugoira_frame_data
) )
@@ -1350,7 +1349,7 @@ class Post < ApplicationRecord
def self.available_includes def self.available_includes
# attributes accessible through the ?only= parameter # attributes accessible through the ?only= parameter
%i[ %i[
uploader approver upload flags appeals parent children notes uploader approver flags appeals parent children notes
comments approvals disapprovals replacements pixiv_ugoira_frame_data comments approvals disapprovals replacements pixiv_ugoira_frame_data
artist_commentary artist_commentary
] ]