Images not loading after merge even when file exists and Upload model exists

I used Merge two Discourse sites into one and it mostly worked, but images from the second site aren’t showing.

I can do something like this:

p=Post.find_by(topic_id: 222435, post_number: 11)
short_url=p.raw.match(/(upload:\/\/.*?)\)/)[1]
up=Upload.sha1_from_short_url(short_url)

and up.url looks like /uploads/default/original/3X/9/e/9ebb54f0e825c05df7f6df271a5cfbdc95a6332c.jpeg and cd /shared; ls uploads/default/original/3X/9/e/9ebb54f0e825c05df7f6df271a5cfbdc95a6332c.jpeg finds the file.

But https://host/uploads/default/original/3X/9/e/9ebb54f0e825c05df7f6df271a5cfbdc95a6332c.jpeg gives me a 404 from nginx.

It would seem like if the Upload exists and the file exists then NGINX would be nice and let me have it. What am I missing?

For some images, I’ve “solved” this problem by pasting in the URL of the image from the test site, which then generates the image, which then gets converted into an upload (the very same upload I just find, as far as I can tell) and then after that if I rebuild the post, it’ll have the image.

I’ve tried to do something like

f=File.open('/shared/uploads/default/original/2X/9/9ebb54f0e825c05df7f6df271a5cfbdc95a6332c.jpeg')
upload = UploadCreator.new(f, 'upload.jpeg').create_for(-1)

to do the same thing as pasting in the remote URL of the image, but that’s not working either.

Hey @RGJ . Have you got a hint on how to get these images that (seem to?) exist in the database and the fileysystem to get rendered when I rebake?

I hate debugging those kind of errors.
Most of the time I just manually execute the code in the controller in a rails console.

This time I guess the 404 might be coming from line 111

What does Discourse.store.list_missing_uploads(skip_optimized: true) give you?

1 Like

That’s how we’re the same. But I’m pretty sure you’re better at it than I am. Thanks very much for your hints.

That’s what I’m trying to do.

That seems like a good guess. Thanks!

nil. skip_optimized: false – same.

I managed to get the uploads for one post fixed, but apparently didn’t make very good notes. :person_shrugging: But I did a bunch of things to get there; I mostly have some hope that it’s possible, at least.

1 Like