Project import *and* export leaves `tmp/cache` files when object storage is enabled for uploads
Problem
Reproduced locally by enabling object storage and exporting a project. Also happens on import.
Doesn't happen with local storage only.
Possible solution
I don't know yet.
I attempted CarrierWave.clean_cached_files!
in Rails console to see if we could run it in a cronjob as a bandaid, but it errored:
[1] pry(main)> CarrierWave.clean_cached_files!
NoMethodError: undefined method `map' for nil:NilClass
from /Users/monozok/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/carrierwave-1.3.1/lib/carrierwave/storage/file.rb:114:in `block in clean_cache!'
Here is the line that raised the error. I think it's because uploader.cache_dir
is calling a class method which seems to return the default CarrierWave cache_dir
(uploads/tmp
) rather than our actual cache_dir
(uploads/-/system/tmp/cache
).
More
For comparison, I also tested:
- Uploading a file to an issue description (FileUploader)
- Uploading a sign in/sign up page logo (AttachmentUploader)
I did not notice a leftover cache file anywhere. Yet ImportExportUploader
inherits AttachmentUploader
and doesn't override much, so that's a bit of a mystery ATM.
Related CarrierWave wiki page, also has interesting issues linked, but ultimately did not lead me to a solution: https://github.com/carrierwaveuploader/carrierwave/wiki/how-to:-delete-cache-garbage-directories