Method: PortalModule::Dts#download

Defined in:
lib/portal_module/dts.rb

#download(org, file_path) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/portal_module/dts.rb', line 37

def download org, file_path
  assert_org_is_configured org
  assert_dl_dir_is_configured
  assert_dir_exists file_path

  dts_page
    .load_org(org_string(org))
    .download

  file_path = Pathname(file_path)
  file_path = file_path + DL_FILENAME if file_path.directory?

  dl_file = download_dir + DL_FILENAME
  wait_for_file(dl_file, PortalModule.configuration.download_timeout)
  assert_file_exists dl_file

  FileUtils.mv dl_file, file_path

rescue Exception => e
  if e.message.include? 'No such file or directory'
    raise IOError, "No such directory - #{file_path}"
  else
    raise e
  end
end