multiwoven-integrations 0.34.10 → 0.34.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3146b56f87f49f572cc5c4ae740846e708137eb55881d87ba7982baa9f89768
4
- data.tar.gz: 0474f983113e4e5b58af75c41c041a2d90f50d448872d23a6435a9711bbd7bca
3
+ metadata.gz: 4051aa0036dc3795ce89575e293c6d0c3e36cb57c143cc39b2c736e04f71461b
4
+ data.tar.gz: e15d6caa850f7de4dcd87b634bf83db384458ec66b24d19a01a5aa4df165b51a
5
5
  SHA512:
6
- metadata.gz: f62121314c055fa88538b0ecbb7c03837d83d6ed1d6a11571e0fece48066739590aab30b8f6d3b301f8cf07dc0c3a681b687b90d4744eb1d5603050291725165
7
- data.tar.gz: 8bbc5c2e576eda8cfaa35241bd2b7edc2cc62eb05c0f7e6edd9947db5bef96946637b5ff5aec5b2c74961c87fc8f13858c7062529ad6194618e0991b2c7c075f
6
+ metadata.gz: bb18eb994768e5dd301714c92b3400929620b53a5c344289b8cf3f66c2d3cf8d70d725cdeadd5b93b97e84c14610da5fc400b7e6f7b66669585fdb8e3f24a012
7
+ data.tar.gz: ee4334676f93a3790c6c1abcdcb76a42a0331deef422620bceb8357a194af2ef09fad9553f73332439384d67866ace0f697c8c75513fc7e05c0944dbff600379
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.34.10"
5
+ VERSION = "0.34.11"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -85,7 +85,7 @@ module Multiwoven::Integrations::Source
85
85
  file_name = ::Regexp.last_match(1).strip
86
86
  file_name = file_name.gsub(/^["']|["']$/, "") # Remove leading/trailing quotes
87
87
  file_name = file_name.gsub("\\", "\\\\\\") # Escape backslashes
88
- download_file_to_local(file_name, sync_config.sync_id)
88
+ download_file_to_local(folder_name, file_name, sync_config.sync_id)
89
89
  else
90
90
  raise ArgumentError, "Invalid command. Supported commands: #{LIST_FILES_CMD}, #{DOWNLOAD_FILE_CMD} <file_path>"
91
91
  end
@@ -111,7 +111,8 @@ module Multiwoven::Integrations::Source
111
111
  end
112
112
  end
113
113
 
114
- def download_file_to_local(file_name, sync_id)
114
+ def download_file_to_local(folder_name, file_name, sync_id)
115
+ query = build_query(folder_name)
115
116
  download_path = ENV["FILE_DOWNLOAD_PATH"]
116
117
  file = if download_path
117
118
  File.join(download_path, "syncs", sync_id, File.basename(file_name))
@@ -121,7 +122,7 @@ module Multiwoven::Integrations::Source
121
122
 
122
123
  # Escape single quotes to prevent query injection
123
124
  escaped_name = file_name.gsub("'", "\\\\'")
124
- query = "mimeType != 'application/vnd.google-apps.folder' and name = '#{escaped_name}'"
125
+ query = "#{query} and name = '#{escaped_name}'"
125
126
 
126
127
  records = get_files(@google_drive, query, 1, 0)
127
128
  raise StandardError, "File not found." if records.empty?
@@ -156,26 +157,25 @@ module Multiwoven::Integrations::Source
156
157
  raise ArgumentError, "Specified folder does not exist" if response.files.empty?
157
158
 
158
159
  parent_id = response.files.first.id
159
- "'#{parent_id}' in parents"
160
+ "'#{parent_id}' in parents and mimeType != 'application/vnd.google-apps.folder'"
160
161
  end
161
162
 
162
- def get_files(client, query, limit, offset)
163
+ def get_files(client, query, limit, _offset)
164
+ next_page_token = nil
163
165
  total_fetched = 0
164
166
  result = []
165
167
 
166
- return result if offset.positive? && !@next_page_token
167
-
168
168
  while total_fetched < limit
169
169
  batch_limit = [MAX_PER_PAGE, limit - total_fetched].min
170
- response = if @next_page_token
171
- client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit, page_token: @next_page_token)
170
+ response = if next_page_token
171
+ client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit, page_token: next_page_token)
172
172
  else
173
173
  client.list_files(include_items_from_all_drives: true, supports_all_drives: true, q: query, fields: FIELDS, page_size: batch_limit)
174
174
  end
175
175
  break if response.files.empty?
176
176
 
177
177
  result.push(*response.files)
178
- @next_page_token = response.next_page_token
178
+ next_page_token = response.next_page_token
179
179
  break unless response.next_page_token
180
180
 
181
181
  total_fetched += response.files.size
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.10
4
+ version: 0.34.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P