Skip to content

Unexpected file upload updating unrelated column #2757

@xanderman

Description

@xanderman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions