529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
|
# File 'lib/cnvrg/files.rb', line 529
def download_file(absolute_path, relative_path, project_home, conflict=false)
res = Cnvrg::API.request(@base_resource + "download_file", 'POST', {absolute_path: absolute_path, relative_path: relative_path})
Cnvrg::CLI.is_response_success(res, false)
if res["result"]
res = res["result"]
return false if res["link"].empty? or res["filename"].empty?
filename = res["filename"]
file_location = absolute_path.gsub(/#{filename}\/?$/, "")
FileUtils.mkdir_p project_home + "/" + file_location
filename += ".conflict" if conflict
File.open("#{project_home}/#{file_location}/#{filename}", "wb") do |file|
file.write open(res["link"]).read
end
else
return false
end
return true
end
|