From b5738e1d4551864c77ba02f4a9807c3ae13976ca Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Mon, 26 Oct 2020 17:43:57 +0000 Subject: [PATCH 1/2] Replace 'export_file' by 'http' to download Google Sheet files --- NEWS.md | 1 + .../datasources/lib/datasources/url/gdrive.rb | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0bcd48e1fc9c..4bb7966f4544 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ Development * Fix Dashboard/Data navigation for free users. Update Data preview texts [#15892](https://github.com/CartoDB/cartodb/pull/15892) * Force CTE materialization in Ghost Tables query to improve performance [#15895](https://github.com/CartoDB/cartodb/pull/15895) * Adapt default Rails mail logs to JSON format [#15894](https://github.com/CartoDB/cartodb/pull/15894) +* Fix export of Google Sheet files larger than 10MB []() 4.42.0 (2020-09-28) ------------------- diff --git a/services/datasources/lib/datasources/url/gdrive.rb b/services/datasources/lib/datasources/url/gdrive.rb index e13384671c6d..5d5272726a50 100644 --- a/services/datasources/lib/datasources/url/gdrive.rb +++ b/services/datasources/lib/datasources/url/gdrive.rb @@ -193,22 +193,25 @@ def get_resource(id) raise DataDownloadError.new(error_msg, DATASOURCE_NAME) end if file.export_links.present? - @drive.export_file(file.id, 'text/csv', download_dest: StringIO.new) do |content, export_err| + @drive.http(:get, file.export_links['text/csv'], download_dest: StringIO.new) do |content, export_err| raise export_err if export_err - return content + + # NOTE: Reinitializing StringIO due to 'content' is not readable + return StringIO.new(content.string) end else @drive.get_file(file.id, download_dest: StringIO.new) do |content, download_err| raise download_err if download_err + return content end end end - rescue Google::Apis::AuthorizationError, Signet::AuthorizationError => ex - raise TokenExpiredOrInvalidError.new("Invalid token: #{ex.message}", DATASOURCE_NAME) + rescue Google::Apis::AuthorizationError, Signet::AuthorizationError => e + raise TokenExpiredOrInvalidError.new("Invalid token: #{e.message}", DATASOURCE_NAME) rescue Google::Apis::BatchError, Google::Apis::TransmissionError, Google::Apis::ClientError, \ - Google::Apis::ServerError => ex - raise DataDownloadError.new("downloading file #{id}: #{ex.message}", DATASOURCE_NAME) + Google::Apis::ServerError => e + raise DataDownloadError.new("downloading file #{id}: #{e.message}", DATASOURCE_NAME) end # @param id string From 03c8591363ff005c63717aee8abbd9b6748f12e1 Mon Sep 17 00:00:00 2001 From: cgonzalez Date: Mon, 26 Oct 2020 18:12:25 +0000 Subject: [PATCH 2/2] Update PR info in 'NEWS.md' --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 4bb7966f4544..b026f463bb2e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,7 +16,7 @@ Development * Fix Dashboard/Data navigation for free users. Update Data preview texts [#15892](https://github.com/CartoDB/cartodb/pull/15892) * Force CTE materialization in Ghost Tables query to improve performance [#15895](https://github.com/CartoDB/cartodb/pull/15895) * Adapt default Rails mail logs to JSON format [#15894](https://github.com/CartoDB/cartodb/pull/15894) -* Fix export of Google Sheet files larger than 10MB []() +* Fix export of Google Sheet files larger than 10MB [#15903](https://github.com/CartoDB/cartodb/pull/15903) 4.42.0 (2020-09-28) -------------------