pfaffman
(Jay Pfaffman)
4월 17, 2018, 1:27오전
1
I’ve got a vbulletin import for a hosted customer. The avatars have disappeared and are now showing as a generic blank person shape like this .
I’m pretty sure that they were there at some point. The URLs look like the should have something. Is there some way that I can find them?
Do you have a backup where you can check the URL?
Are they in the tombstone?
pfaffman
(Jay Pfaffman)
4월 24, 2018, 9:25오후
5
I did a fresh import and all of the avatars are missing. Sidekiq still has 13M things to process, but I don’t see how that could be the problem. I did another import on another site with what I believe to be the same import script and the avatars are fine there.
pry(main)> User.find_by_username('MysteryManAvatar').uploaded_avatar
=> #<Upload:0x0000558a0d31b478
id: 97,
user_id: 114,
original_filename: "clevername.jpg",
filesize: 2028,
width: 90,
height: 67,
url: "/uploads/default/original/1X/080817dcf59ddc838054fba9716b62fce9ae3d83.jpg",
created_at: Thu, 19 Apr 2018 23:51:15 UTC +00:00,
updated_at: Thu, 19 Apr 2018 23:51:15 UTC +00:00,
sha1: "080817dcf59ddc838054fba9716b62fce9ae3d83",
origin: nil,
retain_hours: nil,
extension: "jpg">
But that file isn’t in uploads (or tombstone).
I looked at Avatars not showing after import - #2 by fhe and that didn’t seem to be related.
백업에서 데이터베이스를 복원했습니다 (구버전에서의 DB 마이그레이션이 있었고, backup.sql.gz에는 SQL만 포함되어 있었으며 업로드 파일은 포함되지 않았습니다).
불행히도 사이트에서 아바타가 표시되지 않습니다.. (기본 플레이스홀더만 표시됨)
데이터베이스에 올바르게 저장되어 있고 URL도 정확하며 PNG 파일도 존재하는 것 같습니다:
root@og-app:/var/www/discourse# rails c
[1] pry(main)> User.find_by_username('Overgrow').uploaded_avatar
=> #<Upload:0x0000565323a78880
id: 2936,
user_id: 1,
original_filename: "avatar.png",
filesize: 161585,
width: nil,
height: nil,
url: "/uploads/default/original/2X/f/fbba12aa89b1bc45676efcfa55affd4b7a76edf1.png",
created_at: Sat, 03 Sep 2016 10:26:23 UTC +00:00,
updated_at: Sat, 22 Feb 2020 11:57:35 UTC +00:00,
sha1: "fbbe22aa89b1bc45676efcfa55affd4b7a76edf1",
origin: nil,
retain_hours: nil,
extension: "unknown",
thumbnail_width: nil,
thumbnail_height: nil,
etag: nil,
secure: false,
access_control_post_id: nil,
original_sha1: nil>
다음으로 무엇을 시도해 볼 수 있는지 조언해 주실 수 있을까요? 미리 감사드립니다!
업데이트:
일부 아바타가 백그라운드에서 재생성되었습니다.. 이 과정을 빠르게 진행할 수 있을까요? 아니면 수동으로 실행할 수 있을까요?
제 관찰에 따르면, 이 부분이 문제의 징후일 수 있을까요?
extension: "unknown",
재생성된 것들은 이제 이 필드가 채워진 것 같습니다:
extension: "JPG",
어떤 이유에선지 백업 복원 및 1.6에서 2.5로 Discourse를 마이그레이팅한 후, 내 데이터베이스의 Upload 테이블(파일 포인터는 정확했고 파일도 제자리에 있었습니다)에서 width, height, extension 값이 누락되어 있었습니다.
결국 모든 사용자 정의 업로드된 아바타를 순회하며 extension과 차원을 수정하고, 제가 누락하고 있던 버전 2의 섬네일과 함께 모든 OptimizedImages를 재생성하는 스크립트를 작성하게 되었습니다.
관심 있는 분들을 위해 공유합니다:
fix-avatars.rb
require File.expand_path("../../config/environment", __FILE__)
generated_count = 0
scope = UserAvatar.where("custom_upload_id > 0")
scope.find_each do |ua|
upload_id = ua.custom_upload_id
upload = Upload.find_by(id: upload_id)
unless upload
puts "\nno upload found for this user avatar"
next
end
# fix unknown
if upload.extension === 'unknown'
upload.extension = nil
upload.save!
puts "\rupload_id #{upload.id} extension unknown -> nil"
end
if upload.extension.nil?
puts "\rupload_id #{upload.id} fixing extension"
upload.fix_image_extension
if upload.height == 0 || upload.width == 0
puts "\rupload_id #{upload.id} fixing dimensions"
upload.fix_dimensions!
end
# check optimized version
correct_optimized = OptimizedImage.where(upload_id: upload_id)
.where(version: 2)
if correct_optimized.count < 1
puts "\rupload_id #{upload.id} doesn't have version 2 thumbnails"
# destroy old optimized
puts "\rupload_id #{upload.id} deleting avatars"
optimized = OptimizedImage.where(upload_id: upload_id)
if optimized
optimized.destroy_all
end
#generate optimized
puts "\rupload_id #{upload.id} creating avatars"
Discourse.avatar_sizes.each {|size| OptimizedImage.create_for(upload, size, size, allow_animation: SiteSetting.allow_animated_avatars)}
generated_count += 1
puts "\rGenerated #{generated_count} total avatars"
end
end
end