You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 10, 2022. It is now read-only.
I have raised these together as one might be causing the other.
Firstly, I have a User model with an uploader mounted as photo_thumb. I can store and retrieve images fine. Every user is allocated an oid in the photo_thumb attribute, regardless of whether or not they have provided a photo - is this expected? As a result, my code to determine whether to display the image or use a placeholder is: photo_thumb_url.present? && photo_thumb.file.size > 0
which was working ok, until I wanted to allow the user to delete an image. I did this by calling user.remove_photo_thumb!
which I believe deletes the image from the db, but the user.photo_thumb attribute is still the oid, and when my code calls photo_thumb.file.size, I receive an error
PG::Error: can't open large object: ERROR: large object 41263 does not exist
(41263 is the oid for this users photo_thumb)
I was wondering if you could explain how I can determine initially if a user has provided an image or not (or if the file size test is the best way) - and secondly how I can safely delete a file that has been uploaded, such that it behaves the same as a user that has never uploaded a file.
I am using rails 4 and using the postgresql_lo_streamer gem for the display of images.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Although OP wrote this over a year ago, I recently encountered this as well with ruby 2.0.0 and rails 4.0.13 using carrierwave-postgres 0.1.4. Our PDFs were the ones that were affected. Our .length.zero? checks on views and in our model returned that same error as OP after being batch deleted with carrierwave's remove_pdf! method. Basically rendering any page that called for PDFs that no longer existed, though Postgres still had a reference ID for it, gave us the that error in the logs:
PG::Error: can't open large object: ERROR: large object 61477 does not exist
I should note that deleting pdf's individually (vs batch) still worked for us. r.remove_pdf! on a single entry worked and made the value nil as expected. For whatever reason though, running it against many 100s of records made it go kaput.
How I understand it is that the referenced oid wasn't removed and replaced with nil after a certain while in the batch deletion process. We came up with a workaround/solution.
I have raised these together as one might be causing the other.
Firstly, I have a User model with an uploader mounted as
photo_thumb
. I can store and retrieve images fine. Every user is allocated an oid in thephoto_thumb
attribute, regardless of whether or not they have provided a photo - is this expected? As a result, my code to determine whether to display the image or use a placeholder is:photo_thumb_url.present? && photo_thumb.file.size > 0
which was working ok, until I wanted to allow the user to delete an image. I did this by calling
user.remove_photo_thumb!
which I believe deletes the image from the db, but the user.photo_thumb attribute is still the oid, and when my code calls
photo_thumb.file.size
, I receive an errorI was wondering if you could explain how I can determine initially if a user has provided an image or not (or if the file size test is the best way) - and secondly how I can safely delete a file that has been uploaded, such that it behaves the same as a user that has never uploaded a file.
I am using rails 4 and using the postgresql_lo_streamer gem for the display of images.
Thanks in advance!
The text was updated successfully, but these errors were encountered: