Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected file upload updating unrelated column #2757

Open
xanderman opened this issue Oct 28, 2024 · 0 comments
Open

Unexpected file upload updating unrelated column #2757

xanderman opened this issue Oct 28, 2024 · 0 comments

Comments

@xanderman
Copy link

I have a model with an uploader mounted on remote_document, and code that downloads the file to do a virus scan on it. The code looks roughly like this:

# I can't figure out a better way to download the file locally and check that it worked. Open to suggestions.
cache = document.remote_document.cache!
if cache.nil?
  Rails.logger.warn("download failed")
  document.update(virus_scan_result: :error)
  return
end

path = document.remote_document.file.file
result = ClamScan::Client.scan(location: path)
document.update(virus_scan_result: result.status)

In our S3 logs we noticed unexpected PUT requests, apparently uploading new versions of files. I dug into spans in datadog and was shocked to discover that there is a PUT happening as part of the transaction in this code (I think it's the "happy path" based on logging). The only thing I can guess is that carrierwave's callback decided that the file was modified. Why would there be an upload here? I'm not even updating the remote_document column.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant