diff --git a/app/services/abf_worker_service/base.rb b/app/services/abf_worker_service/base.rb index bc57c487c..13e183de9 100644 --- a/app/services/abf_worker_service/base.rb +++ b/app/services/abf_worker_service/base.rb @@ -60,5 +60,24 @@ module AbfWorkerService end end + def filter_build_lists_without_packages(*build_lists) + ids = [] + build_lists = build_lists.flatten.select do |build_list| + sha1 = build_list.packages.pluck(:sha1).find do |sha1| + !FileStoreService::File.new(sha1: sha1).exist? + end + if sha1.present? + ids << build_list.id + false + else + true + end + end + + BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL) + + build_lists + end + end end \ No newline at end of file diff --git a/app/services/abf_worker_service/container.rb b/app/services/abf_worker_service/container.rb index d35c0cc7e..dee8813a5 100644 --- a/app/services/abf_worker_service/container.rb +++ b/app/services/abf_worker_service/container.rb @@ -9,6 +9,12 @@ module AbfWorkerService def create! cleanup_folder + + if filter_build_lists_without_packages(build_list).blank? + build_list.fail_publish_container + return + end + Resque.push( 'publish_worker', # Low priority 'class' => 'AbfWorker::PublishWorker', diff --git a/app/services/abf_worker_service/rpm.rb b/app/services/abf_worker_service/rpm.rb index 873b788c4..64dca5dc7 100644 --- a/app/services/abf_worker_service/rpm.rb +++ b/app/services/abf_worker_service/rpm.rb @@ -237,24 +237,5 @@ module AbfWorkerService end end - def filter_build_lists_without_packages(build_lists) - ids = [] - build_lists = build_lists.select do |build_list| - sha1 = build_list.packages.pluck(:sha1).find do |sha1| - !FileStoreService::File.new(sha1: sha1).exist? - end - if sha1.present? - ids << build_list.id - false - else - true - end - end - - BuildList.where(id: ids).update_all(status: BuildList::PACKAGES_FAIL) - - build_lists - end - end end \ No newline at end of file diff --git a/spec/services/abf_worker_service/container_spec.rb b/spec/services/abf_worker_service/container_spec.rb index 93a2e5cea..8bf4a62b0 100644 --- a/spec/services/abf_worker_service/container_spec.rb +++ b/spec/services/abf_worker_service/container_spec.rb @@ -12,10 +12,18 @@ describe AbfWorkerService::Container do context '#create!' do it 'creates task' do + expect(build_list).to_not receive(:fail_publish_container) expect(Resque).to receive(:push) subject.create! end + it 'fails when no packages on FS' do + expect(subject).to receive(:filter_build_lists_without_packages).and_return([]) + expect(build_list).to receive(:fail_publish_container) + expect(Resque).to_not receive(:push) + subject.create! + end + end end