How to find any missing images?

Thanks for continuing to work on this, @vinothkannans! :sparkles:

I just tried running the rake posts:missing_uploads task on my site (currently at v2.3.0.beta9 +484), and this is what I got:

# rake posts:missing_uploads
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxx.xxxxxxxxxx..........................x...........................................x.......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................x.................................................................................................................................................................................................................
451 post uploads are missing.

255 uploads are missing.
244 of 255 are old scheme uploads.
139 of 8812 posts are affected.

In other words, it looks like I have:

  • 244 missing old scheme uploads
  • 11 missing uploads
  • 196 missing post uploads

Just as an aside…what’s the difference between a missing upload and a missing post upload? (If I’m reading the output correctly, I have 196 more of the latter.)

Anyway, because I appear to have a lot of missing images, I decided to do a bit more spelunking with PostCustomField.where(name: Post::MISSING_UPLOADS). Consider the first result:

#<PostCustomField:0x0000564c2cef9ee8
  id: 161,
  post_id: 43,
  name: "missing uploads",
  value:
   "[\"https://SITENAME/uploads/default/35/4608d96d1b27846f.png\",\"https://SITENAME/uploads/default/35/4608d96d1b27846f.png\"]",
  created_at: Fri, 17 May 2019 05:26:57 UTC +00:00,
  updated_at: Fri, 17 May 2019 05:26:57 UTC +00:00>

I navigated to https://SITENAME/p/43 and, sure enough, upon examining the post’s Markdown source I found a link to an image at /uploads/default/35/4608d96d1b27846f.png. Interestingly enough, though, the image displays fine and even exists at /var/discourse/shared/standalone/uploads/default/35/4608d96d1b27846f.png on the host server.

So…Discourse appears to think that this image is “missing”, but it’s not—it just hasn’t been migrated to the new upload scheme yet. Is this expected behavior and, if so, is there any way to migrate the other (200+) images like this to the new upload scheme?

Thanks!


Update: I think I may have identified the 11 missing uploads mentioned above…and they really do seem to be missing. Here’s what one of them looks like:

#<PostCustomField:0x0000564c2cf0b2d8
  id: 297,
  post_id: 2203,
  name: "missing uploads",
  value:
   "[\"https://SITENAME/uploads/default/original/1X/900eff3dd456ecaf5280568676c4717e27b46c85.jpg\"]",
  created_at: Fri, 17 May 2019 05:26:57 UTC +00:00,
  updated_at: Fri, 17 May 2019 05:26:57 UTC +00:00>

Note that this particular image was stored under /uploads/default/original/1X/ rather than /uploads/default/{SOME_NUMBER}/. It’s from a 2015 post and I can’t find it in any of my backups, so it—and the other 10 images like it—appear to be well and truly gone. :cry:

Still not sure why I have 196 more missing post uploads than uploads, though…

2 Likes