Skip to content

Commit

Permalink
Merge pull request #2149 from broadinstitute/jb-bulk-download-ignore-…
Browse files Browse the repository at this point in the history
…internal

Ignore unsynced directories in bulk download (SCP-4549)
  • Loading branch information
bistline authored Oct 7, 2024
2 parents 7c49585 + 4f6f387 commit d2f033c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/v1/bulk_download_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def self.find_matching_directories(directory_name, file_type, accession)
when 'nodirs'
[]
when 'all'
study.directory_listings.all
study&.directory_listings&.are_synced || []
else
DirectoryListing.where(name: sanitized_dirname, study_id: study.id, sync_status: true, file_type: file_type)
end
Expand Down
14 changes: 14 additions & 0 deletions test/api/bulk_download_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,4 +484,18 @@ class BulkDownloadControllerTest < ActionDispatch::IntegrationTest
assert_equal %w[FakeHCAProject AnotherFakeHCAProject].sort, hca_accessions.sort
end
end

test 'should ignore unsynced directories' do
study = FactoryBot.create(:detached_study, name: 'Unsynced Dir Test', user: @user, test_array: @@studies_to_clean)
files = 1.upto(30).map do |i|
{
name: "_scp_internal/subdir/output_#{i}.tsv",
size: i * 100,
generation: SecureRandom.random_number(10000..99999)
}
end
directory = DirectoryListing.create(study:, file_type: 'tsv', name: '_scp_internal', files:, sync_status: false)
assert directory.persisted?
assert_empty Api::V1::BulkDownloadController.find_matching_directories('all', '', study.accession)
end
end

0 comments on commit d2f033c

Please sign in to comment.