أفاتار مفقود بعد الاستيراد

لدي استيراد من vBulletin لعميل مستضاف. اختفت الصور الرمزية (الأفاتار) وأصبحت تظهر الآن كشكل بشري فارغ عام مثل هذا.

أنا متأكد تقريبًا من أنها كانت موجودة في وقت ما. تبدو الروابط وكأنها يجب أن تحتوي على شيء ما. هل هناك طريقة للعثور عليها؟

Maybe related to that?

Do you have a backup where you can check the URL?
Are they in the tombstone?

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 and that didn’t seem to be related.

لقد قمت باستعادة قاعدة البيانات من النسخة الاحتياطية (كان هناك بعض ترحيلات قاعدة البيانات من الإصدار القديم، ولم يتضمن ملف backup.sql.gz سوى SQL وليس ملفات التحميل).

لسوء الحظ، لا تظهر الصور الرمزية (الأفاتار) على الموقع.. (يظهر فقط الناصح الافتراضي)

يبدو أنها موجودة بشكل صحيح في قاعدة البيانات وأن الرابط صحيح وملف 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 (كانت مؤشرات الملفات صحيحة والملفات في مكانها).

لقد انتهيت بإنشاء سكريبت يمر عبر جميع صور الرموز المخصصة المرفوعة ويصحح الامتداد والأبعاد ويعيد إنشاء جميع OptimizedImages مع صور مصغرة من الإصدار 2 التي كنت أفتقر إليها.

ولأي شخص مهتم، ها هو:

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 "\nلم يتم العثور على ملف مرفق لهذا رمز المستخدم"
    next
  end
  
  # إصلاح غير معروف
  if upload.extension === 'unknown'
    upload.extension = nil 
    upload.save!
    puts "\rupload_id #{upload.id} الامتداد غير معروف -> nil"
  end

  if upload.extension.nil?
    puts "\rupload_id #{upload.id} إصلاح الامتداد"

    upload.fix_image_extension

    if upload.height == 0 || upload.width == 0
      puts "\rupload_id #{upload.id} إصلاح الأبعاد"
      upload.fix_dimensions!
    end

    # التحقق من النسخة المحسنة
    correct_optimized = OptimizedImage.where(upload_id: upload_id)
      .where(version: 2)

    if correct_optimized.count < 1
      puts "\rupload_id #{upload.id} لا يحتوي على صور مصغرة من الإصدار 2"

      # تدمير المحسنات القديمة
      puts "\rupload_id #{upload.id} حذف الرموز"
      optimized = OptimizedImage.where(upload_id: upload_id)

      if optimized
        optimized.destroy_all
      end

      # إنشاء محسنات
      puts "\rupload_id #{upload.id} إنشاء الرموز"
      Discourse.avatar_sizes.each {|size| OptimizedImage.create_for(upload, size, size, allow_animation: SiteSetting.allow_animated_avatars)}

      generated_count += 1

      puts "\rتم إنشاء #{generated_count} رمزًا إجماليًا"

    end
  end

end