في تجربتك الثانية، يتخطى Discourse عمليات التحميل لأنها موجودة بالفعل في جدول uploads. يتجنب Discourse الكتابة فوق الملفات المحملة الموجودة إلا إذا تم توجيهه صراحةً.
يمكنك محاولة إضافة مقتطف الكود أدناه في attachment_importer.rb (discourse/script/import_scripts/phpbb3/importers/attachment_importer.rb at main · discourse/discourse · GitHub) قبل استدعاء @uploader.create_upload سيضمن ذلك حذف أي ملف تم تحميله موجود بنفس اسم الملف أولاً، مما يجبر Discourse على إعادة تحميله.
existing_upload = Upload.find_by(original_filename: filename)
if existing_upload
existing_upload.destroy
puts "Deleted existing upload: #{filename}"
end
upload = @uploader.create_upload(user_id, path, filename)