Missing images in discourse website. while they exist in upload folder

I just tried to change the title of an old topic. Then I realized that all images in the topic are now transparent.png and not showing properly.

rake uploads:recover followed by rake posts:rebake didn’t fix the problem.

I can access the image by https://talk.zabanshenas.com/uploads/default/original/3X/8/7/8726fbef7b69ac8226d28568b46f3e06afe2fb4f.jpeg

the upload itself is : ![164389418-how-i-met-your-mother-wallpapers|666x500](upload://jhBYRiSdEO0a8JYypd6XapJbpaD.jpeg)

However when I do :

Upload.where( "url LIKE '%8726fbef7b69ac8226d28568b46f3e06afe2fb4f%'" )
I get
=> []

any idea?

if I upload the exact same image again somewhere else, the old post would also show the image after rebake. so I think its something with indexing some of old uploaded files. How can I re index all uploaded files again? Or even better, indexing missing ones.

Update:

I read some rake tasks and saw rake posts:recover_uploads_from_index which seems to fix my issue. However I’m getting the following error:

undefined method `split' for nil:NilClass
from /var/www/discourse/app/models/site_setting.rb:151:in `s3_base_url'

I dont have s3 uploads enabled for my website :face_with_monocle: :face_with_monocle:

Update:

I made a temporary ugly fix for above error (commenting this line) and run the rake task. but it wasn’t what i was thinking:

Searching for upload://dC9HyffX3S1XbwwdUOsHe5aMyJX.jpeg (dC9HyffX3S1XbwwdUOsHe5aMyJX) in index                                                                                                             
Skipping upload://dC9HyffX3S1XbwwdUOsHe5aMyJX.jpeg in https://talk.zabanshenas.com/t/topic/4430/1 cause it appears to have a short file name                                                               
Searching for upload://kWx14u8XkQ8qd6NvOoDLN6usTl8.jpeg (kWx14u8XkQ8qd6NvOoDLN6usTl8) in index                                                                                                             
Skipping upload://kWx14u8XkQ8qd6NvOoDLN6usTl8.jpeg in https://talk.zabanshenas.com/t/topic/4430/1 cause it appears to have a short file name  

I went further into the rake task rake uploads:recover. I think there is something wrong in the following line:

https://github.com/discourse/discourse/blob/e3b1d1a7183c2f68c4e9acdd2faac453d9430e1f/lib/upload_recovery.rb#L105

as far as i understand here all files in uploads/default/original should be added to @paths. However I tried to print @paths into a file and I only see tombstone files is listed.

Am I missing something here? :thinking: @CvX

I think it should be like

concat(Dir.glob(File.join(
      Rails.root, "public", Discourse.store.upload_path,
      'original',
      '**',
      '*.*'
    )))