lib/carrierwave/uploader/cache.rb in carrierwave-0.5.7 vs lib/carrierwave/uploader/cache.rb in carrierwave-0.5.8

- old
+ new

@@ -88,10 +88,15 @@ end ## # Caches the given file. Calls process! to trigger any process callbacks. # + # By default, cache!() uses copy_to(), which operates by copying the file + # to the cache, then deleting the original file. If move_to_cache() is + # overriden to return true, then cache!() uses move_to(), which simply + # moves the file to the cache. Useful for large files. + # # === Parameters # # [new_file (File, IOString, Tempfile)] any kind of file object # # === Raises @@ -108,10 +113,14 @@ self.cache_id = CarrierWave.generate_cache_id unless cache_id @filename = new_file.filename self.original_filename = new_file.filename - @file = new_file.copy_to(cache_path, permissions) + if move_to_cache + @file = new_file.move_to(cache_path, permissions) + else + @file = new_file.copy_to(cache_path, permissions) + end end end end ##