From c3f499e7c8656fa09b333b88950c70f7377f95f9 Mon Sep 17 00:00:00 2001 From: Jan Provaznik Date: Fri, 8 Jun 2018 22:06:08 +0200 Subject: Use upload ID instead of model ID in lease key For FileUploaders it's possible that a model has many uploads and if lease key is created only from model id, it causes that the model's uploads can not be migrated in parallel because the exclusive lease key would be same for all uploads of the model. --- spec/uploaders/object_storage_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'spec/uploaders') diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index 0bc5b6751b3..902fc0bc030 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -332,6 +332,18 @@ describe ObjectStorage do expect { uploader.use_file }.to raise_error('exclusive lease already taken') end end + + it 'can still migrate other files of the same model' do + uploader2 = uploader_class.new(object, :file) + uploader2.upload = create(:upload) + uploader.upload = create(:upload) + + when_file_is_in_use do + expect(uploader2).to receive(:unsafe_migrate!) + + uploader2.migrate!(described_class::Store::REMOTE) + end + end end describe '#fog_credentials' do -- cgit v1.2.3